Example #1
0
        if ($status === 2) {
            $qb->where('isOnline', true);
            $qb->where('isValidated', true);
        }
        return $qb;
    }
    public static function scope_recent($qb)
    {
        $qb->where('created_at', '<=', DB::expr('NOW()'));
    }
}
class Author extends SimpleAR\Orm\Model
{
    protected static $_tableName = 'authors';
    protected static $_columns = array('firstName' => 'first_name', 'lastName' => 'last_name', 'age');
    public static function scope_women(QueryBuilder $qb)
    {
        return $qb->where('sex', 1);
    }
}
class User extends SimpleAR\Orm\Model
{
    protected static $_tableName = 'USERS';
    protected static $_columns = array('firstName', 'lastName' => 'name', 'name' => 'name', 'age');
    protected static $_relations = array('followers' => array('type' => 'many_many', 'model' => 'User'));
}
// Normally, this is done by autoloader.
Blog::wakeup();
Article::wakeup();
Author::wakeup();
User::wakeup();
Example #2
0
 public function testTablesStorage()
 {
     Article::wakeup();
     $this->assertInstanceOf('SimpleAR\\Orm\\Table', Article::table());
 }