Esempio n. 1
0
 /**
  * Initialize a new user filter on an active record.
  * It uses the table name and the database adapter from the Active Record.
  *
  * @param Phprojekt_ActiveRecord_Abstract $record     An active record.
  * @param string                          $identifier The identifier usually the column to filter.
  * @param mixed                           $value      The value to filter.
  *
  * @return void
  */
 public function __construct(Phprojekt_ActiveRecord_Abstract $record, $identifier, $value)
 {
     $info = $record->info();
     $cols = $info['cols'];
     $identifier = Phprojekt_ActiveRecord_Abstract::convertVarToSql($identifier);
     if (!in_array($identifier, $cols)) {
         throw new InvalidArgumentException('Identifier not found');
     }
     $this->_identifier = $identifier;
     $this->_value = $value;
     parent::__construct($record->getAdapter());
 }
Esempio n. 2
0
 /**
  * Returns the number of the models of the given type in this subtree.
  *
  * @param $model The activeRecord module used to get the data.
  * @param $where The clause to determine matching objects. Optional.
  */
 public function getRecordsCount(Phprojekt_ActiveRecord_Abstract $model, $where = null)
 {
     $projectIds = array_keys($this->_index);
     if (empty($projectIds)) {
         return 0;
     }
     if (!is_null($where)) {
         $where .= ' AND ';
     }
     $where .= $model->getAdapter()->quoteInto('project_id IN (?)', $projectIds);
     return $model->count($where);
 }