Description:
Return a selection of database table fields using the Zend_Db adapter with Zend Framework
Solution
It’s easier to create an adapter of the database table class and use it in returning the desired values. This grants speed, clean code and accuracy.
Example:
$customersTable = new DbTable_CustomersTable;
$adapter = $customersTable ->getAdapter();
$select = $adapter->select();
$select->from(array(‘cu’ => $customersTable ->getName()),
array(DbTable_CustomerRow::CUSTOMER_NAME));
$select->where(
‘cu.’. DbTable_CustomerRow::EMAIL .’ LIKE “admin%”‘);return $result = $adapter->fetchAll($select);
The example loads the Customers table class and runs the select of the Customer_name fields that match the “admin” email address.