【发布时间】:2014-11-14 19:53:44
【问题描述】:
据此http://php.net/manual/en/language.variables.scope.phpbind_result 应该无法更改我的变量。
$query = 'SELECT username, status FROM table WHERE id = ?';
$id = 5;
$stmt = $mysqli->prepare($query);
$stmt->bind_param('i', $id);
$stmt->execute();
$stmt->bind_result($username, $status);
$stmt->fetch();
// Now I can use $username and $status
echo "$username has the status of $status";
为什么会这样,它是如何工作的,我如何在我自己的 php 类/方法中做到这一点?
【问题讨论】: