News Feed
Sections




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

Liip Blog:
Table Inheritance with Doctrine
March 28, 2012 @ 09:30:09

On the Liip blog there's a recent post looking at table inheritance with Doctrine, the popular PHP ORM tool. In the post, Daniel Barsotti talks about a database model that needed some updating due to their searching needs.

Our first idea, and it was not that bad, Drupal does just the same, was to have a database table with the common fields, a field containing the type of item (it's either an event or a blog post) and a data field where we serialized the corresponding PHP object. This approach was ok until we had to filter or search LabLog items based on fields that were contained in the serialized data.

To resolve the issue they turned to multiple table inheritance, relating the LabLogItem to both a BlogPost and Event. They also show how it could be modeled with a single table, but opt for the multiple method. Included in the post is the Doctrine-based code showing how to create the parent entity for the LabLogItem and the two child entities for the blog post and event. There's also a brief snippet showing how to use them with the EntityManager.

0 comments voice your opinion now!
table inheritance doctrine orm tutorial multiple


blog comments powered by Disqus

Similar Posts

DevShed: Performing Basic Tasks with MySQL 4.1 and Above, using mysqli with PHP 5

NETTUTS.com: Run Your Own TinyURL Service With Phurl

DevShed: Cleaning up Array Elements, POST and GET Requests with Filters in PHP 5

SitePoint PHP Blog: Lightning-fast WordPress with PHP-FPM and nginx

The Bakery: Nine New Tutorials, Helpers and Plugins for CakePHP


Community Events





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


application framework library project code list podcast configure developer api bugfix laravel introduction interview community language series release wordpress threedevsandamaybe

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