$request_id_col和$request_id是字符串。但是,表中的request_id_col类型是一个整数。
$stmt = $db->prepare(' SELECT r.qty, d.name
FROM requested_devices r
JOIN devices d ON r.device_id = d.id
WHERE r.:request_id_col = :request_id
ORDER BY r.id');
$stmt->bindParam(':request_id_col', $request_id_col);
$stmt->bindParam(':request_id', $request_id);
$stmt->execute();我收到了错误
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''sample_id' = '101' ORDER BY r.id' at line 4'如何正确使用bindParam进行查询?
发布于 2015-01-24 10:57:30
不能绑定表名或列名。只有价值。
https://stackoverflow.com/questions/28124725
复制相似问题