Use adapter with Zend_Db


Return a selection of database table fields using the Zend_Db adapter with Zend Framework


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.


$customersTable = new DbTable_CustomersTable;
$adapter = $customersTable ->getAdapter();
$select = $adapter->select();
$select->from(array(‘cu’ => $customersTable ->getName()), 
‘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.

About admin

Just another php developer trying to give something back to the community.
This entry was posted in Best practices, SQL, Zend Framework and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s