3

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.

1
  • Why don't you use DbTable—>Mapper—>Model? than you'll have Zend_Db_Table per table, and use them in mappers to craete models Commented Mar 5, 2012 at 13:27

2 Answers 2

2

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,

Sign up to request clarification or add additional context in comments.

Comments

0

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...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.