[英]Sample PDO Query don't work
I have a simple SQL query that is not working. 我有一个不起作用的简单SQL查询。 I have tried everything I know to fix this query, but to no avail.
我已经尽我所能解决此查询,但无济于事。
$Data = $connection->prepare("SELECT * FROM EXAMPLE");
The table on the database exists, and the connection to the database is set properly. 数据库上的表存在,并且与数据库的连接已正确设置。
I have also tried this: 我也尝试过这个:
$Data = $connection->prepare("SELECT ID FROM EXAMPLE WHERE EXAMPLE1=:EXAMPLE1 ");
$Data->execute(array(
':EXAMPLE1' => $EXAMPLE1,
));
If your connection is fine.. 如果您的连接没问题。
$Data=$connection->prepare("SELECT ID FROM EXAMPLE WHERE EXAMPLE1 = :EXAMPLE1");
$Data->execute(array(
':EXAMPLE1' => $EXAMPLE1,
));
$result = $Data->fetchAll();
Or 要么
$result = array();
$sql = "SELECT ID FROM EXAMPLE WHERE EXAMPLE1 = {$EXAMPLE1};";
foreach ($connection->query($sql) as $row) {
$result[] = $row;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.