Created
December 3, 2014 13:02
-
-
Save elderdosantos/2b9e1812e7676238e7c0 to your computer and use it in GitHub Desktop.
Yii: CDbCriteria with Yii::app()->db->createCommand()
This file contains hidden or 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
<?php | |
/** | |
* To use CDbCriteria with createCommand follow this tip: | |
*/ | |
$criteria = new CDbCriteria(); | |
$criteria->compare('id', $this->id); | |
$criteria->addCondition('user.id in (select userid from user_groups where group_type = 1'); | |
$command = Yii::app()->db->createCommand(); | |
$command->from('vci_veiculo'); | |
$command->andWhere($criteria->condition, $criteria->params); | |
$results = $command->queryAll(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment