![]() |
|
Snippets |
|
Example Table static methods for retrieving data. Passing query objects to allow you to modify and reuse existing methods.
static function retrieveUsers($query = null) { if( $query === null ) { $query = new Doctrine_Query(); } $query->select('u.*'); $query->from('User u'); $users = $query->execute(); return $users; } static function retrieveUsersWithProfile($query) { if( $query === null ) { $query = new Doctrine_Query(); } $query->select('p.*') $query->innerJoin('u.UserProfile p'); return UserTable::retrieveUsers($query); } static function retrieveUserByUsername($username, $query = null) { if( $query === null ) { $query = new Doctrine_Query(); } $query->where('u.username = ?', $username); $users = UserTable::retrieveUsers($query); return $users[0]; }