7
我試圖使用自定義字符串選擇一些值。下面是我的代碼
$this->db->from('posted');
$st="infor='rent' AND (typeq='in' OR typeq='out')";
$this->db->where($st);
$q = $this->db->get();
數據庫出錯
Error Number: 1054 Unknown column ‘infor=‘rent’’ in ‘where clause’ SELECT * FROM (`posted_ads`) WHERE `infor=‘rent’` AND (typeq=‘in’ OR typeq=‘out’) Filename: C:\wamp\www\parklot\system\database\DB_driver.php Line Number: 330
我認爲這個問題是怎麼把的
WHERE `infor='rent'`
當我manualy執行此代碼它完美的作品。
WHERE infor='rent'
我如何擺脫
``
,因爲它會自動添加
如果你經常做類似的事情,有用的創造,其周圍添加的表名和字段蜱的功能 - 或寫適當蜱一個簡單的包裝,函數調用'DB-> where' (當然有'false'第三個參數)。 – uzsolt
這是一個恥辱,這不是在這裏的文檔。 http://ellislab.com/codeigniter/user-guide/database/active_record.html – Tyguy7
@ user1253085它在那裏。你一定忽略了。 –