通常你会有这样的查询:
$qry = $this->db->prepare(" SELECT * FROM `table` WHERE status = :status ");
$qry->execute(array(':status'=>'whatever value'));
所以我想做的是这样的事情:
$qry = $this->db->prepare(" SELECT * FROM `table` WHERE status = ? ");
$qry->execute(array('whatever value'));
是否有某种属性可以设置来完成此任务?
答案 0 :(得分:4)
$sth = $dbh->prepare('SELECT name, colour, calories
FROM fruit
WHERE calories < ? AND colour = ?');
$sth->execute(array(150, 'red'));
$red = $sth->fetchAll();