我在 pdo 上遇到了一个大问题,似乎没有人能帮助我 - 所以我决定问你们 :-)
try {
$links = $database->prepare("SELECT * FROM aTable WHERE visible=:visible AND access<=:access AND category=:category ORDER BY orderNum ASC");
$links->bindValue(':visible',$first,PDO::PARAM_INT);
$links->bindValue(':access',$second,PDO::PARAM_INT);
$links->bindValue(':category',$third,PDO::PARAM_STR);
$links->execute();
print_r($asdf);
print_r($database->errorInfo());
print_r($links->errorInfo());
while($row = $links->fetch(PDO::FETCH_ASSOC)){
print_r($row);
}
} catch (PDOException $e) {
echo $e->getMessage();
}
Database-Connection 完美运行,errorInfo() 都返回:
Array
(
[0] => 00000
[1] =>
[2] =>
)
现在,这段代码不知何故没有得到任何 $row's。但是,如果我将准备语句替换为以下几行:
$sql = "SELECT * FROM woody_sidebar WHERE visible=$first AND access<=$second AND category=$third ORDER BY orderNum ASC";
$links = $database->prepare($sql);
(并删除 bindValue 语句)代码就像魅力一样工作!
我不知道我做错了什么,因为根本没有抛出错误 - 你们中有人知道我可以尝试什么吗?
谢谢