Andy's Blog » verycd, pdo orm, emule, php paris, paris PHP, idiorm, Paris, php idiorm, paris orm, Idiorm&Paris-PHP5 PDOORM&AR|AndysBlog » Idiorm & Paris - PHP5 + PDO ORM & AR

Idiorm & Paris - PHP5 + PDO ORM & AR


Idiorm is an ORM object-relational mapper and fluent query builder.

If you prefer to think about tables and joins, you should probably be using Idiorm.

Paris is an AR Active Record implementation based on Idiorm.

If you prefer to think about model objects and relationships, you should probably be using Paris.

http://j4mie.github.com/idiormandparis/

Idiorm Example:

$user = ORM::for_table('user')
    ->
where_equal('username', 'j4mie')
    ->
find_one();
 
$user->first_name = 'Jamie';
$user->save();
 
$tweets = ORM::for_table('tweet')
    ->
select('tweet.*')
    ->
join('user', array(
        
'user.id', '=', 'tweet.user_id'
    
))
    ->
where_equal('user.username', 'j4mie')
    ->
find_many();
 
foreach ($tweets as $tweet) {
    
echo $tweet->text;
}

Paris Example:

class User extends Model {
    
public function tweets() {
        
return $this->has_many('Tweet');
    
}
}
 
class Tweet extends Model {}
 
$user = Model::factory('User')
    ->
where_equal('username', 'j4mie')
    ->
find_one();
$user->first_name = 'Jamie';
$user->save();
 
$tweets = $user->tweets()->find_many();
foreach ($tweets as $tweet) {
    
echo $tweet->text;
}

Incoming search terms:

Tags: ORM, Idiorm, Paris, PDO, PHP5

本文地址: http://blog.21andy.com/20120528/2044.html