我有表测试:
Test:
id | name
1 | aaa
2 |
3 | ccc
4 | aaa
5 |
6 | ddd
我想要名称不为空的结果:
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。
关于php - 如何用 Doctrine 查询 NOT NULL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7305468/