Last active
December 13, 2015 19:09
-
-
Save stvnwrgs/4960618 to your computer and use it in GitHub Desktop.
Fix for query function to use Models dbCriteria for creating query. So you can edit these criterias with beforeFind()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Performs the actual DB query and populates the AR objects with the query result. | |
* This method is mainly internally used by other AR query methods. | |
* @param CDbCriteria $criteria the query criteria | |
* @param boolean $all whether to return all data | |
* @return mixed the AR objects populated with the query result | |
* @since 1.1.7 | |
*/ | |
protected function query($criteria,$all=false) | |
{ | |
$this->setDbCriteria($criteria); | |
$this->beforeFind(); | |
$this->applyScopes($criteria); | |
if(empty($criteria->with)) | |
{ | |
if(!$all) | |
$criteria->limit=1; | |
$command=$this->getCommandBuilder()->createFindCommand($this->getTableSchema(),$this->getDbCriteria()); | |
return $all ? $this->populateRecords($command->queryAll(), true, $criteria->index) : $this->populateRecord($command->queryRow()); | |
} | |
else | |
{ | |
$finder=new CActiveFinder($this,$criteria->with); | |
return $finder->query($criteria,$all); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment