I have never really appreciated ORM's so I think that the only way to remedy this is to build a basic one myself so I can see what all the hubbub is. So with that in mind, what are the basic features I would need to include to make a semi-usable ORM?
As far as I can tell, it would basically need to work like this for the end programmer:
/*
* Create a user
*/
$user = new User();
$user->name = 'Joe';
$user->email = '[email protected]';
$user->save();
unset($user);
/*
* Create a game
*/
$game = new Game();
$game->name = 'soccer';
$game->save();
/*
* Set all users as players
*/
$users = ORM::factory('users');
$users = $users->findAll();
foreach ( $users as $user ) {
$user->setGame($game);
$user->save();
}
unset($users);
/*
* Get all games and show all users
*/
$games = ORM::factory('games')->findAll();
foreach( $games as $game ) {
print $game->name;
print 'Users in game:';
foreach( $game->users as $user ) {
print $user->name;
}
}
Each model class would extend the ORM class which would have all the basic methods
Other usefull features would be things like:
User::find(34)
Could anyone else tell me what I would need. I've been looking at some of the libraries like Doctrine, EZPDO, dORM, and KohanaPHP but I can't seem to find a library that is easy to digest to figure out what the feature list would need to be to tackle this project.
I found an image detailing some of ruby's offerings and some more info on the IgnitedRecord Project.
Here is a list of basic and extended features ORM is supposed to have: http://madgeek.com/Articles/ORMapping/EN/mapping.htm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With