Пример #1
0
 public function findAllBySql($sql, $params = array())
 {
     $this->beforeFind();
     if (($criteria = $this->getDbCriteria(false)) !== null && !empty($criteria->with)) {
         $this->resetScope(false);
         $finder = new CActiveFinder($this, $criteria->with);
         return $finder->findAllBySql($sql, $params);
     } else {
         $command = $this->getCommandBuilder()->createSqlCommand($sql, $params);
         return $this->populateRecords($command->queryAll());
     }
 }
Пример #2
0
 /**
  * Finds all active records using the specified SQL statement.
  * @param string $sql the SQL statement
  * @param array $params parameters to be bound to the SQL statement
  * @return array the records found. An empty array is returned if none is found.
  */
 public function findAllBySql($sql, $params = array())
 {
     Yii::trace(get_class($this) . '.findAllBySql()', 'system.db.ar.CActiveRecord');
     $this->beforeFind();
     if (($criteria = $this->getDbCriteria(false)) !== null && !empty($criteria->with)) {
         $this->_c = null;
         $finder = new CActiveFinder($this, $criteria->with);
         return $finder->findAllBySql($sql, $params);
     } else {
         $command = $this->getCommandBuilder()->createSqlCommand($sql, $params);
         return $this->populateRecords($command->queryAll());
     }
 }