php - $stmt->num_rows 即使在调用 store_result 之后也返回 0

标签 php mysqli prepared-statement

我希望使用 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 - $stmt->num_rows 即使在调用 store_result 之后也返回 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1594805/

相关文章:

php 数据库最少 4 个字母?

php - 总登录时间

php - 在 php 脚本末尾关闭和/或终止 mysqli 连接?

java - 从文本框中获取的数据库表中的字段中减去值

mysql - 如何在 java 准备语句中设置 mysql 十进制值?

php - Laravel 5 : DOMPDF(0. 8.3) 每页页眉页脚

php - 从表中选择逗号分隔的记录以及用户图像

插入语句中的sql问号

php - 如何在 year[i] 中使用 android studio 中的 for 循环存储 json 字符串值?

PHP:准备数据数组以安全插入 MySQL