$stmt->num_rows 即使在调用 store_result 后也返回 0 [英] $stmt->num_rows returning 0 even after calling store_result

查看:65
本文介绍了$stmt->num_rows 即使在调用 store_result 后也返回 0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望使用 mysqli/prepared 语句计算下面查询返回的记录数:

I am looking to count the number of records returned by the query below using mysqli / prepared statements:

$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();

这篇关于$stmt->num_rows 即使在调用 store_result 后也返回 0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆