Organizational Research By

Surprising Reserch Topic

Zend DbTable add where in if() statement


I get my data by this way:

$table = new Application_Model_DbTable_FooBar();

$data = $table
->select()
->where('id = ?', (int) $id)
->query()
->fetchAll();

and want to add a separate where clause in an if() statement.
Something like that:

if($foo == "bar") {
    $data->where('foo = ?, 'bar');
}

So I tried something like that, but it didn't work.

$table = new Application_Model_DbTable_FooBar();

$table
->select()
->where('id = ?', (int) $id);

if($foo == "bar") {
    $table->where('foo = ?, 'bar');
}

$data = $table->query()->fetchAll();
asked Dec 10, 2013 in Zend by rajesh
0 votes
60 views



Related Hot Questions



Government Jobs Opening


...