我有这个 PDO:
$id = 1;
$title = 'resourceName';
$url = 'resourceURL';
$result = array($title => $url);
include('../dbconnect.php');
$pdo = new PDO("mysql:host=$db_host;dbname=$db_name;", $db_user, $db_password);
$stmt = $pdo->prepare("SELECT resourceName, resourceURL FROM Resources WHERE categoryID = :id");
$stmt->bindParam(':id', $id);
$stmt->execute(array_values($result));
$row = $stmt->fetchAll();
print_r($row);
我刚刚收到此错误:警告:PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
如何使 PDO 结果成为一个数组,其中 resourceName 是键,resourceURL 是值?