num_rows
作品只有当我使用mysqli->store_result()
。这意味着它只适用于缓冲结果。有人能解释为什么会发生这种情况?NUM_ROWS工作只与`store_result()`
当我使用mysqli->store_result()
然后num_rows
作品。否则它表示0
。
function retrievearticle($mysqli, $articleid)
{
echo $articleid;
$query="select ArticleText,ArticleTitle from article where ArticleId=?";
$stmt=$mysqli->stmt_init();
$stmt->prepare($query);
$stmt->bind_param('i', $articleid);
$stmt->execute();
$stmt->store_result();
echo "here 2";
$stmt->bind_result($ArticleText, $ArticleTitle);
$stmt->fetch();
echo $stmt->num_rows;
}
请参阅[此链接](http://php.net/manual/fr/mysqli-result.num-rows.php#105289)。 – D4V1D
不用担心。这里是一个[链接到一个更加不言自明的注释](http://php.net/manual/en/mysqli-stmt.num-rows.php#71988) – D4V1D
@ D4V1D现在好了,我会认为这是一个答案,如果你可以把它放在那里.. –