我确实有以下教义查询。我的数据库是MySQL。
public static function getLastList($user_id){
$user_id = 123;
$q = Doctrine_Query::create()
->from('list l')
->innerJoin('l.listUser lu ')
->where('lu.user_id = ?', $user_id)
->orderBy('e.created ASC')
->limit(1)
->execute();
if ($q == NULL) {
print_r('false');
} else {
print_r('not false');
}
}
我的数据库中没有user_id = 123的条目。所以我期望的是“ false”。但是结果是“不假”。
1.)为什么?
2.)如何在“是的,有用户”或“否,没有用户”之间使用此特定查询进行划分?
谢谢!
贡纳尔
最佳答案
execute()
返回Doctrine_Collection
您可以通过调用count()
来检查集合的大小
if ($q->count() == 0) {
print_r('false');
} else {
print_r('not false');
}
关于mysql - Doctrine 查询结果,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10871021/