PropelでIS NOT NULLする時の注意点
addで条件を指定するときに第2引数をnullにしないと上手く通らない罠。
これは忘れやすいぞ。。。というか仕様が変だろ。
- OK
<?php $id = $this->getRequestParameter('id'); $c = new Criteria(); $c->add(TestPeer::ID, $id); $c->add(TestPeer::NAME, null, Criteria::ISNOTNULL); $test = TestPeer::doSelect($c);
- NG
<?php $id = $this->getRequestParameter('id'); $c = new Criteria(); $c->add(TestPeer::ID, $id); $c->add(TestPeer::NAME, Criteria::ISNOTNULL); $test = TestPeer::doSelect($c);
参考:symfony framework forum: General discussion => ISNOTNULL in Queries?