示例#1
0
 public function executeRecentUpdates()
 {
     $q = new Doctrine_RawSql();
     $q->select('{e.*}, {i.*}, {u.*}, {p.*}')->from('entity e LEFT JOIN image i ON (e.id = i.entity_id AND i.is_deleted = 0) LEFT JOIN sf_guard_user u ON (u.id = e.last_user_id) LEFT JOIN sf_guard_user_profile p ON (u.id = p.user_id)')->where('e.is_deleted IS NULL OR e.is_deleted = ?', false)->addComponent('e', 'Entity e')->addComponent('i', 'e.Image i')->addComponent('u', 'e.LastUser u')->addComponent('p', 'u.Profile p')->orderBy('e.updated_at DESC')->limit(@$this->limit ? $this->limit : 10);
     if (@$this->group) {
         if (count($userIds = $this->group->getUserIds())) {
             $q->andWhereIn('e.last_user_id', $userIds);
             if (count($entityIds = $this->group->getEntityIds())) {
                 $q->andWhereIn('e.id', $entityIds);
             }
         } else {
             $q->andWhere('1=0');
         }
     }
     if ($this->network) {
         $q->leftJoin('ls_list_entity le ON (e.id = le.entity_id)')->addComponent('le', 'e.LsListEntity le')->andWhere('le.list_id = ?', $this->network['id']);
     }
     $this->entities = $q->execute();
 }