How to query NOT NULL with Doctrine?(如何使用 Doctrine 查询 NOT NULL?)
问题描述
我有表测试:
Test:
id | name
1 | aaa
2 |
3 | ccc
4 | aaa
5 |
6 | ddd
我想要名称不为 NULL 的结果:
I want result where name is NOT NULL:
aaa
ccc
aaa
ddd
我怎样才能得到:
Doctrine_Core::getTable('Test')->findBy('name', NOTNULL??) <-doesnt working
在模型中:
$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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!