Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zend db table model and query multiple tables

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.

like image 342
ktm Avatar asked Feb 05 '26 18:02

ktm


1 Answers

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,

like image 98
dinopmi Avatar answered Feb 09 '26 08:02

dinopmi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!