3
votes

Just like in codeigniter model class, can we have multiple methods calling different tables in zend framework model that extends zend_db_table_abstract ?

protected $_name = table_name

when defining table name like that, Is there a way to query multiple table having no affect of that protected property ? I am mainly concern about this because I want to have model for homepage which will deal with frontend website and fetch data from different table so that i don't have to touch backend db-table models.

2
Why don't you use DbTable—>Mapper—>Model? than you'll have Zend_Db_Table per table, and use them in mappers to craete modelsbalkon_smoke

2 Answers

2
votes

You can also access the DB adapter member in the table and query it directly, specifying a table name of your choice.

For instance, for a select, you can do something like the following:

$select = $this->getAdapter()->select();
$select->from('tableName', $fields);
// ...
$results = $this->getAdapter()->fetchAll($select);

Hope that helps,

0
votes

Try protected $_name = array(1=>'table1', 2=>'table2', /*etc...*/);

And add a foreach() to your code when the query is made, like this:

foreach ($_name as $table)
{
    // execute your query
}

It should work, I used this in my CMS for the AdminZone...