views:

113

answers:

3

Is it possible with Kohana v3 Query Builder (Kohana v3 being possibly the most poorly documented #$@$%...) to use the IS NOT NULL operator?

The where($column, $op, $value) method requires all three parameters and even if I specify

->where('col', 'IS NOT NULL', '')

it builds and invalid query eg.

SELECT * FROM table WHERE col IS NOT NULL '';

Is this a bug? Also -- despite some great advantages (like template controllers and a nice auth system) Kohana is horribly undocumented. Frustratingly so. Holy F**k. I'm wondering whether I should have gone with 2.xx but it's too late in the project to switch. arg.

$frustration++;
+1  A: 

Not sure (it's 3 AM right now) but ->where('col', '', DB::expr('IS NOT NULL')) might works.

Crozin
GENIUS. You sir, are a saint.
FelixHCat
I think it's better to put the 'IS NOT' as the second argument and the value just being NULL. Just like Gerry answered. Using a DB::expr is nice, but adds unnecessary extra overhead (in this case)
Caspar
+4  A: 

This works with the ORM module and is a little less typing.

->where('col', '!=', NULL);
Gerry
A: 

This should work:

->where('col', '=', NULL);
biakaveron