News Feed
Sections




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

Michael Nitschinger's Blog:
Introducing Relationships in Lithium
March 05, 2012 @ 11:21:39

In this new post to his blog Michael Nitschinger introduces relationships in using the Lithium framework - functionality to link your models to each other to create dependencies.

The model relationship support in Lithium is one of the hottest topics on IRC lately, so I thought it would be a good idea to blog about it. Currently, Lithium supports 1:1 and 1:n relationships for relational databases. [...] This post gives you a little background on relationship types and their database representations before we implement a simple example in PHP.

He gives some code (and schema) examples of creating these relationships between tables for the two types - one to one and one to many. He also touches on the zero-to-zero relationships as well, nothing that they can be some of the most tricky to work with. He includes the SQL and the code you'll need to produce a blog example with models for Authors, Posts and Groups. Using the belongsTo/hasMany/hasOne variables he defines the relationships and uses the "with" keyword in the find calls to pull in those relations.

0 comments voice your opinion now!
relationship lithium framework model database introduction


blog comments powered by Disqus

Similar Posts

Rami Alnawas: How to unit test code with Phalcon MVC Models

Stefan Mischook's Blog: Note to CodeIgniter nerds: please, no looping code in your views.

Nick Lo's Blog: Custom View Helpers in Zend Framework

Brian Swan's Blog: Getting Started with PHP and SQL Azure

Fabien Potencier's Blog: Create your own framework... on top of the Symfony2 Components (part 5)


Community Events

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


framework symfony2 conference configure introduction community performance api series laravel php7 podcast example library voicesoftheelephpant opinion application release install interview

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