Part of the EllisLab Network

Bug Report

$this->db->where - Associative array method - escaping error

Date: 05/14/2007 Severity: Critical
Status: Resolved Reporter: Thadeus
Version: 1.5.3
Keywords:

Description

the method mentioned above produces errors, as it is not escaping correctly and when an array value is empty it should use NULL as a value, but instead it puts nothing, which breaks the sql statement.

Code Sample

$somearray
(
    [
0] => 3
    
[1] => 1
    
[2] =>
    [
3] =>
    [
4] =>
    [
5] =>
)

applying this array to the function:
$this->db->where('table', $somearray)

Expected Result

SELECT * FROM table WHERE 0 = ‘3’ AND 1 = ‘1’ AND 2 = ‘2’ AND 3 =NULL AND 4=NULL AND 5=NULL

Actual Result

SELECT * FROM table WHERE 0 = ‘3’ AND 1 = ‘1’ AND 2 = 2 AND 3 AND 4 AND 5

Comment on Bug Report

Page 1 of 1 pages
Posted by: coolfactor on 14 May 2007 5:21pm
coolfactor's avatar

This NULL (PHP’s value) vs NULL (MySQL’s value) has been brought up before. I agree that the Active Record class should translate between them seamlessly.

Posted by: Thadeus on 14 May 2007 5:41pm
no avatar

@coolfactor:
i filed another bug concerning active record (escaping behaviour in general), but the function used there does at least the NULL value translation correctly:
http://codeigniter.com/bug_tracker/bug/1819/

Name:

Email:

Location:

URL:

Remember my personal information

Notify me of follow-up comments?