News Feed
Sections




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

Gonzalo Ayuso's Blog:
Building an ORM with PHP
September 13, 2010 @ 12:44:14

In this new post to his blog Gonzalo Ayuso looks at building an ORM (don't worry, he recommends something like Doctrine first) as an exercise to understand how they're constructed and how one could fit his goals.

What's the motivation for me to build this ORM? The answer is a bit ambiguous. I like SQL. It allows us to speak with the database in a very easy way. [...] So the idea I figured out was to create a set of classes based on my tables, in a similar way than traditional ORMs to help me to autocomplete the fields and table names.

He creates a simple example with a "test" table with three columns with a mapped class (in the "Orm" namespace) that will allow IDEs to follow down the path to fetch the data from the "id", "field1" and "field3" columns. The complete code listing for his example is at the end of the post - PHP 5.3 friendly, of course. Some trigger and scaffolding examples are also included.

1 comment voice your opinion now!
orm tutorial example database doctrine autocomplete


blog comments powered by Disqus

Similar Posts

PHPMaster.com: Working with Dates and Times in PHP and MySQL

Zend Developer Zone: Reading Access Databases with PHP and PECL

Henrik Bjørnskov's Blog: Travis & Composer sitting in a tree K-I-S-S-I-N-G

PHPBuilder.com: An Introduction to Graphs Using PEAR\'s Image_Graph Package

Imagine Easy: Pushing the limits of metaprogramming in PHP: aspect oriented design


Community Events





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


community podcast framework list introduction threedevsandamaybe library api series bugfix symfony opinion deployment release developer language laravel zendserver interview tips

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