0
我ahve問題與如下因素:Zend的分貝PDO沒有返回結果
$sql = "SELECT e.*, c.name city_name, u.*, IF(l.item IS NULL, 0, 1) as iLike, DATE_FORMAT(e.date, '%h:%i') hour, DATE_FORMAT(e.date, '%d/%c/%Y') day, DATE_FORMAT(e.date, '%c') month
FROM `events` e
LEFT OUTER JOIN `like` l ON l.item = e.uuid AND l.user = :user
LEFT OUTER JOIN city c ON c.city = e.city
LEFT OUTER JOIN user u ON u.user = e.user
WHERE
e.deleted = 0
AND DATE(e.date) >= CURDATE()
AND e.user = :user
ORDER by e.date ASC
";
$select = $eventsModel->getAdapter();
$select->setFetchMode(Zend_Db::FETCH_ASSOC);
$prepare = $select->query($sql, array('user'=>$this->user_id));
此代碼返回的結果,如果我硬編碼:用戶查詢。例如:
$sql = "SELECT e.*, c.name city_name, u.*, IF(l.item IS NULL, 0, 1) as iLike, DATE_FORMAT(e.date, '%h:%i') hour, DATE_FORMAT(e.date, '%d/%c/%Y') day, DATE_FORMAT(e.date, '%c') month
FROM `events` e
LEFT OUTER JOIN `like` l ON l.item = e.uuid AND l.user = 23
LEFT OUTER JOIN city c ON c.city = e.city
LEFT OUTER JOIN user u ON u.user = e.user
WHERE
e.deleted = 0
AND DATE(e.date) >= CURDATE()
AND e.user = 23
ORDER by e.date ASC
";
$select = $eventsModel->getAdapter();
$select->setFetchMode(Zend_Db::FETCH_ASSOC);
$prepare = $select->query($sql);
這只是開始發生的時候,我們搬到我們的代碼到新的服務器, 新的操作系統是Debian的6,squeze中,MySQL 5.5,PHP 5.3.21。
謝謝
不幸的是不可行,應該重寫整個代碼庫以適應這種變化。我們知道這是有效的。 – 2013-02-12 17:51:29
此外,另一個有趣的事情是,如果我們使用:用戶只有一次,而不是2倍,MySQL查詢的查詢工作。 – 2013-02-12 17:51:56
哦,我沒有注意到,用戶使用了兩次,你需要在你的參數數組申報2件:'陣列(「用戶」 => $這個 - > USER_ID,「l.user」 => $這個 - > USER_ID)',或也許'陣列($這 - > USER_ID,$這個 - > USER_ID)' – sdespont 2013-02-12 17:54:15