我有以下代码:
$criteria=new CDbCriteria;
$criteria->condition = ' action_id
IN(SELECT action_id FROM action_type WHERE action_name = \'EnableGame\') ';
$criteria->compare('task_id','= '.$taskData->task_id, false, 'AND');
$criteria->compare('value', '= '.$gameData->game_id, false, 'AND');
$enablingActions = TaskActions::model()->findAll($criteria);
在compare
方法中task_id
,value
不会与提供的值进行比较,但不会在函数中传递。以下是 Yii 如何将上面的代码转换为 SQL 查询:
Querying SQL: SELECT * FROM "task_actions" "t"
WHERE
((
action_id IN(SELECT action_id FROM action_type WHERE action_name = 'EnableGame'
) )
AND (task_id=:ycp0))
AND (value=:ycp1)
为什么我看到占位符:ycp0
而ycp1
不是我设置的值?谢谢!