My question is straight forward. How do I query a mysql view table in Zend Framework since technically a view is not a table.
You can query it the same way you would a normal table using Zend_Db directly, or using Zend_Db_Table.
The following work for me:
$db = Zend_Db_Table::getDefaultAdapter();
$select = $db->select()
->from('view_not_table')
->where('id > ?', 64);
$results = $select->query()->fetchAll();
// or, setting up a Zend_Db_Table
class Application_Model_DbTable_ViewNotTable extends Zend_Db_Table_Abstract
{
protected $_name = 'view_not_table';
protected $_primary = 'id';
protected $_sequence = false;
}
$table = new Application_Model_DbTable_ViewNotTable();
$table->fetchAll();
$table->select()
->from($table)
->where('id = ?', $id);