讓我們說,我有:Zend框架的查詢,添加到字符串
$query = $this->select()
->where('name LIKE ?','%something%');
->where('section LIKE ?','%something%');
->where('cars LIKE ?','%something%');
............
............
你明白了吧!
但我想添加where()子句的查詢只讓我們說如果.. $ x = 0;像這樣:
$select = $this->select();
if($x == 0):
//add to the $this->select(); so it will be $this->select()->where('section LIKE ?','%something%');
$select->where('section LIKE ?','%something%');
endif;
if($x == 0):
/*add to the $this->select(); so it will be
$this->select()->where('section LIKE ?','%something%')
->where('cars LIKE ?','%something%');
*/
$select->where('cars LIKE ?','%something%');
endif;
當然,這個東西不起作用,但我想你已經明白我想做什麼了!
最好的問候,
創建查詢格式其實,你可以使用該代碼$選擇 - >其中()在操作中添加更多。 – Chris 2010-01-13 00:55:45
是啊我知道,那就是我所做的,我有一個錯誤..那就是爲什麼不工作! – Uffo 2010-01-13 01:30:35