Yii不返回是db

时间:2015-04-22 09:21:52

标签: php yii

这是我的疑问:

SELECT * FROM mytable WHERE `USER` = '1599' AND `id` = '124253' AND `wednesday` IS NULL

这是php代码:

$check = Test::model()->find("id =:id and user =:user and ".$day." =:day ", array(":id" => $check_lunch_per_day, ":user" => $user, 'day'=> null));

另一次尝试:

$check = Test::model()->find("id =:id and user =:user and ".$day." =:day ", array(":id" => $check_lunch_per_day, ":user" => $user, 'day'=> 'IS NULL'));

但检查结果始终为空。我该怎么办?如果它为null,我想得到星期三列值。

1 个答案:

答案 0 :(得分:0)

这应该有效,

:day设为IS NULL

    $check = Test::model()->find("id =:id and user =:user and ".$day." =:day ",
array(":id" => $check_lunch_per_day, ":user" => $user, ':day'=> 'IS NULL'));