Exemple #1
0
 /**
  * Get a paged list of entities of a particular type
  *
  * @param int   $pageNumber The page number for pagination
  * @param int   $pageSize   The page size for pagination
  * @param array $orderBy    The order by clause
  *
  * @return array An array of BaseEntityAbstract
  */
 public function findAll($searchActiveOnly = true, $pageNumber = null, $pageSize = DaoQuery::DEFAUTL_PAGE_SIZE, $orderBy = array())
 {
     $results = Dao::findAll($this->_query->setSelectActiveOnly($searchActiveOnly), $pageNumber, $pageSize, $orderBy);
     $this->_pageStats = Dao::getPageStats();
     $this->resetQuery();
     return $results;
 }
Exemple #2
0
 /**
  * finds if a join table record for many to many relationship exists
  *
  * @param DaoQuery $qry         The dao query
  * @param string   $rightEntity The other entity
  * @param int      $leftId      The id of the left side entity
  * @param int      $rightId     The id of the right side entity
  *
  * @return bool
  */
 public static function existsManyToManyJoin(DaoQuery $qry, $rightClass, $leftId, $rightId)
 {
     $leftClass = $qry->getFocusClass();
     $qry->where(strtolower(substr($leftClass, 0, 1)) . substr($leftClass, 1) . 'Id = ? and ' . strtolower(substr($rightClass, 0, 1)) . substr($rightClass, 1) . 'Id = ?');
     $results = self::_getResults($qry, $qry->generateSelectForMTM($rightClass), array($leftId, $rightId), self::AS_ARRAY);
     return count($results) > 0;
 }
 /**
  * Lazy load a many-to-many relationship
  *
  * @param string $property The property that we are trying to load
  *
  * @return BaseEntityAbstract
  */
 protected function loadManyToMany($property)
 {
     // Grab the DaoMap data for both ends of the join
     $this->__loadDaoMap();
     $cls = DaoMap::$map[strtolower(get_class($this))][$property]['class'];
     $obj = new $cls();
     $obj->__loadDaoMap();
     $thisClass = get_class($this);
     $qry = new DaoQuery($cls);
     $qry->eagerLoad($cls . '.' . strtolower(substr($thisClass, 0, 1)) . substr($thisClass, 1) . 's');
     // Load this end with an array of entities typed to the other end
     DaoMap::loadMap($cls);
     $alias = DaoMap::$map[strtolower($cls)]['_']['alias'];
     $field = strtolower(substr($thisClass, 0, 1)) . substr($thisClass, 1);
     $this->{$property} = Dao::findByCriteria($qry, sprintf('`%sId`=?', $field), array($this->getId()));
     return $this;
 }