如何使用Doctrine查询NOT NULL? [英] How to query NOT NULL with Doctrine?

查看:150
本文介绍了如何使用Doctrine查询NOT NULL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有表测试:

Test:
id | name 
1  | aaa
2  | 
3  | ccc
4  | aaa
5  | 
6  | ddd

我想要结果,其中name不为NULL:

I want result where name is NOT NULL:

aaa
ccc
aaa
ddd

如何获取:

Doctrine_Core::getTable('Test')->findBy('name', NOTNULL??) <-doesnt working

/ p>

and in model with:

$this->createQuery('u')
     ->where('name = ?', NOTNULL ???) <- doesnt working
     ->execute();


推荐答案

尝试这个:

$this->createQuery('u')
     ->where('name IS NOT NULL')
     ->execute();

这是标准的SQL语法。 Doctrine不会将Null值转换成适当的sql。

which is standard SQL syntax. Doctrine doesn't convert Null values into proper sql.

这篇关于如何使用Doctrine查询NOT NULL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆