我希望使用 mysqli/准备好的语句来计算下面的查询返回的记录数:
$mysql = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or die('There was a problem connecting to the database');
$stmt = $mysql->prepare('SELECT id,vcref,jobtitle,jobtype,jobintro,closingdate FROM jobs WHERE active = 1');
$stmt->execute();
$stmt->store_result;
$stmt->bind_result($id,$vcref,$jobtitle,$jobtype,$jobintro,$closingdate);
$stmt->fetch();
$totalLiveJobs = $stmt->num_rows();
输出始终为0
最佳答案
$stmt->store_result;
应该是:
$stmt->store_result();
关于php - 即使在调用 store_result 之后 $stmt->num_rows 返回 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50123332/