Example #1
0
 /**
  * Get a set of results that match a particular where clause
  *
  * @param string $criteria      The search criteria string
  * @param array  $params        The parameters of the query to replace '?'(without the quotes)
  * @param array  $orderByParams The order clause Array[Entity.Field] = 'direction'
  *
  * @return array
  */
 public function findByCriteria($criteria, array $params = array(), $searchActiveOnly = true, $pageNumber = null, $pageSize = DaoQuery::DEFAUTL_PAGE_SIZE, array $orderByParams = array())
 {
     $results = Dao::findByCriteria($this->_query->setSelectActiveOnly($searchActiveOnly), $criteria, $params, $pageNumber, $pageSize, $orderByParams);
     $this->_pageStats = Dao::getPageStats();
     $this->resetQuery();
     return $results;
 }
 /**
  * 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;
 }