Active Record, empty WHERE() call results in invalid SQL syntax |
|||
|---|---|---|---|
| Date: | 05/15/2008 | Severity: | Major |
| Status: | Duplicate | Reporter: | XtraFile |
| Version: | 1.6.2 | ||
| Keywords: | Libraries, Database Class | ||
Description
There is a bug in the active record database class that results in invalid syntax if someone submits an empty WHERE call, EG:
======================
db->where(‘id, ’‘);
_It should equal_
WHERE id = ’‘
_It really equals_
WHERE id =
=====================
I would consider this a serious bug. Because of this i have include a patch to resolve this bug.
———————————————————————
Index: DB_active_rec.php
===================================================================
—- DB_active_rec.php (revision 1165)
+++ DB_active_rec.php (working copy)
@@ -461,6 +461,10 @@
$v = ’ ’.$this->escape($v);
}
}
+ else
+ {
+ $v = " ''";
+ }
}
else
{
Code Sample
$this->db->get_where('table', array('avitar !=' => ''));
Expected Result
SELECT * FROM (`condos`) WHERE avitar != ’‘
Actual Result
SELECT * FROM (`condos`) WHERE avitar !=
Comment on Bug Report
| Posted by: XtraFile on 15 May 2008 5:47pm | |
|
|
The system has stripped whitespace out of the patch, so here is a download to the file. |
| Posted by: XtraFile on 15 May 2008 6:48pm | |
|
|
There was an erro in my code, fuxoring sessions. Add after line 463: else if($v === ’‘) -Matt |
