我正在尝试将fetch_assoc(mysqli)的结果转换为字符串
,但出现错误
mysqli_result类的对象无法转换为字符串
我需要获取SELECT查询结果的整数,以便将此返回值传递给另一个函数。
$delay = getDelayRisorsa();
setMaintenancePreno($delay); // I get error here
function getDelayRisorsa()
{
global $log,$conn;
$queryDelay = "SELECT DelayPreno FROM room WHERE IDRoom = 4";
$resDelay = $conn->query($queryDelay); //Eseguo Query SQL
while($row = $resDelay->fetch_assoc())
{
$resultDelay = $row["DelayPreno"];
}
return $resDelay;
}
答案 0 :(得分:0)
您返回错误的变量。返回$resultDelay
function getDelayRisorsa()
{
global $log,$conn;
$queryDelay = "SELECT DelayPreno FROM room WHERE IDRoom = 4";
$resDelay = $conn->query($queryDelay); //Eseguo Query SQL
while($row = $resDelay->fetch_assoc())
{
$resultDelay = $row["DelayPreno"];
}
return $resultDelay;
}