[英]PHP PDO error using SQLite3
這是代碼:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
if ($_GET['id']) {
$id = $_GET['id'];
$db = new SQLite3('database.db');
$sth = $db->query('SELECT * FROM channels WHERE id = :id');
$sth->bindValue(':id', $id);
while ($row = $sth->fetchArray()) {
var_dump($row);
}
}
?>
這是錯誤消息:
致命錯誤:在第12行的/var/www/index.html中調用未定義的方法SQLite3Result :: bindValue()
我不了解“ Call to undefined method
含義,因為我在PHP自己的網站上關注這些示例。
prepare()
哪里是? 如果您正確地遵循了手冊,那么您將准備一個語句,該語句將提供bindValue()
方法:)
通過直接在數據庫句柄上執行查詢,您將無法獲得語句提供的功能。 您必須為其創建一個SQLite3Stmt
對象。
像這樣
$stmt = $db->prepare('SELECT * FROM channels WHERE id=:id');
$stmt->bindValue(':id', $id, SQLITE3_INTEGER);
$result = $stmt->execute();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.