Php MySQLi准备的语句没有返回任何内容

Php MySQLi准备的语句没有返回任何内容,php,mysql,mysqli,prepared-statement,sqlbindparameter,Php,Mysql,Mysqli,Prepared Statement,Sqlbindparameter,我正在尝试从literalquery调用转换为准备好的语句 我在班上有以下功能: public function read ($identifier) { $stmt = static::$mysqli->prepare('SELECT * FROM `table` WHERE `id` = ?;'); $stmt->bind_param('i', $identifier); $stmt->execute(); var_dump($stmt-&

我正在尝试从literal
query
调用转换为准备好的语句

我在班上有以下功能:

public function read ($identifier) {
    $stmt = static::$mysqli->prepare('SELECT * FROM `table` WHERE `id` = ?;');
    $stmt->bind_param('i', $identifier);
    $stmt->execute();

    var_dump($stmt->num_rows);
}
我从phpMyAdmin知道数据库中有一个id为1的行,但是如果我调用
read(1)
行数
为0

但是,如果我使用此逻辑:

public function read ($identifier) {
    $result = static::$mysqli->query('SELECT * FROM `table` WHERE `id` = '.(int) $identifier.';');
    var_dump($result->num_rows);
}

我得到了1。

尝试调用
$stmt->store_result()execute()
后的code>。
执行后,结果尚未存储在内存中,您必须获取所有行,或者调用
num\u rows
变量的
store\u result()
,以显示受影响的实际行数