Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在yii中创建CDBC标准_Yii_Yii Components_Yii Events - Fatal编程技术网

在yii中创建CDBC标准

在yii中创建CDBC标准,yii,yii-components,yii-events,Yii,Yii Components,Yii Events,如何为查询创建cdbcriteria,如: select * from table_name where 'profile_type'='*'OR 'profile_type'=$usertype AND 'location'='*'OR 'location'=$country 您可以直接通过以下条件 注:这是一种方法。这不是最终的解决办法 $criteria = new CDbCriteria; $criteria->condition = "(profile_type ='*'

如何为查询创建cdbcriteria,如:

select * from table_name where 'profile_type'='*'OR 'profile_type'=$usertype  AND 'location'='*'OR 'location'=$country

您可以直接通过以下条件

注:这是一种方法。这不是最终的解决办法

$criteria = new CDbCriteria;
$criteria->condition  = "(profile_type ='*' OR profile_type = $usertype)  AND (location ='*' OR location = $country)";

$model = Model_name::model()->findAll($criteria );

你可以试试这样的东西:

$criteria = new CDbCriteria;
$criteria->condition  = "(profile_type='*' OR profile_type=:prof ) AND 
                         (location='*' OR  location=:loc ) ";

$criteria->params = array(':prof' => $usertype, ':loc' => $country);

$model = MyModel::model()->findAll($criteria );

你不认为你应该用双引号把条件括起来吗?