我对关系中相同字段的第二个标准有疑问
$criteria->with = array( 'Rel1',
'Rel1.Rel2' => ['alias'=>'attrType']);
$criteria->condition = 'Type=:type';
// first condition with Re1.value and Rel2.name - without second works fine
$criteria->addCondition("attrType.name='start' AND Rel1.value <= NOW()");
// second criteria with Re1.value and Rel2.name
$criteria->addCondition("attrType.name='end' AND Rel1.value > NOW()");
$criteria->order = 'Rel1.value DESC';
$criteria->params = [':type'=> 22];
$result = SomeModel::model()->findAll($criteria);
没有第二个条件我有多个包含起始和结束名称的记录。如果我以第二个条件运行,我找到了0个记录。请帮助:/
答案 0 :(得分:0)
您的混合状况如下:
attrType.name='start' AND attrType.name='end' AND
Rel1.value <= NOW() AND Rel1.value > NOW()
此部分Rel1.value <= NOW() AND Rel1.value > NOW()
始终为假