Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"WHERE column IS NOT NULL" with Kohana v3 Query Builder

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 '';
like image 600
MeatFlavourDev Avatar asked Sep 26 '10 00:09

MeatFlavourDev


People also ask

Is not null in MySQL query?

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.

How do you make a column NOT NULL in MySQL?

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.

How do I select not null in phpmyadmin?

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.


2 Answers

The operator is not escaped:

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

No need to use DB::expr, Kohana already supports what you want.

like image 173
shadowhand Avatar answered Sep 28 '22 09:09

shadowhand


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

->where('col', '!=', NULL);
like image 35
Gerry Shaw Avatar answered Sep 28 '22 09:09

Gerry Shaw