爲什麼這返回一個值,當我直接查詢數據庫時,我得到多個值?的爲什麼這會返回一行而不是幾行?
$statement = $sql->prepare
('select * from items where user_id = (select id from user where ?=? limit 1)');
$statement->bindParam('s', $property);
$statement->bindParam('s', $value);
$statement->execute();
$data = $statement->fetch(PDO::FETCH_ASSOC);
echo json_encode($data);
酷!謝謝,你知道爲什麼我不能執行(array($ property,$ value))而不是bindParam嗎?由於某種原因,似乎不起作用。 – luis 2015-04-04 06:56:45
請參閱#示例2,在此鏈接中http://php.net/manual/en/pdostatement.execute.php並嘗試通過,如 – 2015-04-04 06:59:01
不起作用。 #example 3 – luis 2015-04-04 07:01:44