我不明白 fetch 函数的概念。
我正在编写“PHP 解决方案”一书中的教程,并且正在使用 MySQL 改进来更新数据库中的某些内容。
这是代码:
if (isset($_GET['article']) && !$_POST) {
$sql = 'SELECT article_id, title, article
FROM journal WHERE article_id = ?';
$stmt = $conn->stmt_init();
if ($stmt->prepare($sql)) {
$stmt->bind_param('i', $_GET['article_id']);
$stmt->bind_result($article_id, $title, $article);
//execute the query, and fetch the result
$OK = $stmt->execute();
$stmt->fetch();
}
}
那么 fetch 实际上在做什么呢?我认为 execute() 函数将信息发送到数据库,然后将真/假值返回给 $OK 变量。
fetch() 是否在 $stmt 中存储了一些东西?有人知道它在做什么吗?