Sooner or later, you’ll find yourself in a need of filtering out NULL
values along with some other criterion. You’ve tried ->where(array('something' => $value, 'other_thing IS NOT NULL'))
and got an error. I’m sure you’ve spent considerable time looking for some kind of negation that would work with NULL
and I bet you’ve even tried to stick NSqlLiteral
somewhere in there. I’m here to rescue you.
Two solutions:
- Split your where into two calls.
This will causewhere()
to detect correctly that there are no arguments to the condition and allow you to use'other_thing IS NOT NULL'
.-
span class=”st0″>’job’)
-
->where(‘project_id’, $projectId)
-
->where(‘vendor_id IS NOT NULL’);
-
- Begin with NOT
You can negate the whole condition by placing NOT at the beginning.-
span class=”st0″>’job’‘project_id’ => $projectId,
-
‘NOT vendor_id’
I suppose this applies to the original database library NotORM as well. Haven’t tested it though.
Tags: Nette Framework 2.0-beta (revision f38d86f released on 2011-08-24)
-