0
我通過這種方式讓我的數據:Zend的DBTABLE加入其中if()語句
$table = new Application_Model_DbTable_FooBar();
$data = $table
->select()
->where('id = ?', (int) $id)
->query()
->fetchAll();
,想添加一個單獨的where子句中的if()語句。
類似的東西:
if($foo == "bar") {
$data->where('foo = ?, 'bar');
}
所以,我想類似的東西,但沒有奏效。
$table = new Application_Model_DbTable_FooBar();
$table
->select()
->where('id = ?', (int) $id);
if($foo == "bar") {
$table->where('foo = ?, 'bar');
}
$data = $table->query()->fetchAll();
完美!謝謝你! – StinsonMaster