PARAMS:我如何可以綁定在PHP PDO參數凡在聲明
$params = 2826558; # Necessary Object
$params = array(2826558,2677805,2636005); # NULL
執行代碼:
$data = $this->DQL_selectAllByCampaign_id()
->execute(array($params))
->fetchAll();
var_dump($data);
SQL查詢:
$this->DQL_selectAllByCampaign_id = $this->conn->prepare(
"SELECT * FROM `banner` WHERE `campaign_id` IN (?)"
);
如果$params
是整數,退貨必需的對象。 如果$params
是數組,則返回NULL。
畢竟,事實上它應該工作......我該怎麼做?
見http://stackoverflow.com/questions/920353/php-pdo-can-i-bind-an-array-to-an-in-condition – andr 2010-07-30 18:27:33
不幸的是,我沒有直接訪問PDO對象,我只有$ this-> DQL_selectAllByCampaign_id()當前數組值。我試圖implode(',',$ params),但不成功,在數組的第一個元素中只接收id的行。 – ajile 2010-07-30 18:54:36