Exemplo n.º 1
0
 /**
  * @param null $db
  *
  * @return array|null|CActiveRecord
  */
 public function one($db = null)
 {
     $cmd = $this->createCommand($db);
     $row = $this->finder->findBySql($cmd->getSql(), $cmd->params);
     if ($row !== null) {
         $models = $this->populate([$row]);
         return reset($models) ?: null;
     } else {
         return null;
     }
 }
Exemplo n.º 2
0
 /**
  *
  * @param array $sql
  * @param array $params
  * @return CStubActiveRecord 
  */
 public function findBySql($sql, $params = array())
 {
     if (CStubActiveRecord::isUnittests()) {
         return CallFactory::call($this, 'findBySql');
     }
     return parent::findBySql($sql, $params);
 }
 public function findBySql($sql, $params = array())
 {
     return $this->prepareRecord(parent::findBySql($sql, $params));
 }