Is it possible with Kohana v3 Query Builder 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 '';
Here is an example of how to use the MySQL IS NOT NULL condition in a SELECT statement: SELECT * FROM contacts WHERE last_name IS NOT NULL; This MySQL IS NOT NULL example will return all records from the contacts table where the last_name does not contain a null value.
To enforce NOT NULL for a column in MySQL, you use the ALTER TABLE .... MODIFY command and restate the column definition, adding the NOT NULL attribute.
When editing the field in the Structure tab, look for the "NULL" checkbox. When un-checked, this is the equivalent of the NOT NULL statement. Show activity on this post. If you uncheck this property then it means that it is not null.
The operator is not escaped:
->where('col', 'IS NOT', NULL)
No need to use DB::expr, Kohana already supports what you want.
This works with the ORM module and is a little less typing.
->where('col', '!=', NULL);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With