News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Evan Coury's Blog:
Using ZendDb's TableGateway & HydratingResultSet to return rows as custom enties
July 02, 2012 @ 09:32:55

Evan Coury has a new post to his blog about using ZendDb's TableGateway (from the Zend Framework 2) along with the HydratingResultSet feature to let you build objects from your database results.

The new ZendDb in Zend Framework 2 has a handy feature which allows you to specify your own entity/model class to represent rows in your database tables. This means you can tell ZendDb to return each row as a populated instance of your own custom objects. Keep in mind that this is simply a convenience feature, and not meant to serve as a fully-featured ORM. If you're looking for a full-blown ORM, have a look at Doctrine 2.

He includes some example SQL to create a "book" table and the ZF2 code to create the Book model, set up the database connection and generate the hydrated data set from the results. An example of doing an insert into the table and then pull it back out from the TableGateway object.

0 comments voice your opinion now!
tutorial zendframework2 tablegateway hydratingresultset entity model object


blog comments powered by Disqus

Similar Posts

Matthew Weier O'Phinney: RESTful APIs with ZF2, Part 2

Adrian Schneider' Blog: Testing Zend_Mail

Jani Hartikainen's Blog: Decoupling models from the database: Data Access Object pattern in PHP

PHPMac.com: Building and Installing Apache 2.2.2 and PHP 5.1.3 (or 5.1.4) on Mac OS X 10.4.6

Brian Nelson's Blog: Writing A Reverse Proxy in PHP5


Community Events





Don't see your event here?
Let us know!


symfony laravel release voicesoftheelephpant list tool composer library version opinion interview community podcast series conference framework security language introduction artisanfiles

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework