Manage NULL value on ActiveRecord |
|||
|---|---|---|---|
| Date: | 03/14/2008 | Severity: | Minor |
| Status: | Bogus | Reporter: | Alessandro Pagnin |
| Version: | 1.6.1 | ||
| Keywords: | |||
Description
When a variable as a NULL value, the SQL has to change.
=== Example ===
$this->db->get_where(’table’, array(’col’=> $a));
generate:
SELECT * FROM table WHERE col = $a;
but if $a == NULL I think that the correct code is:
SELECT * FROM table WHERE col is NULL;
Reference:
http://dev.mysql.com/doc/refman/5.0/en/working-with-null.html
Code Sample
$this->db->get_where('table', array('col'=> $a));
Expected Result
// With $a != NULL
SELECT * FROM table WHERE col = $a;
// With $a == NULL
SELECT * FROM table WHERE col IS NULL;
Actual Result
SELECT * FROM table WHERE col = $a;
Comment on Bug Report
| Posted by: Seppo on 20 March 2008 1:10pm | |
|
|
I’m actually getting SELECT * FROM (`table`) WHERE `col` IS NULL as expected.
This is my code
function index()
|
