db->where() issue |
|||
|---|---|---|---|
| Date: | 05/13/2008 | Severity: | Critical |
| Status: | Resolved | Reporter: | stanleyxu |
| Version: | 1.6.2 | ||
| Keywords: | |||
Description
The following code
$db->where(‘field’,’‘);
will be translated as
WHERE `field`=
It should be
WHERE `field`=’‘
The quotation marks are missing.
Code Sample
$db->where('field','');
Expected Result
WHERE `field`=’‘
Actual Result
WHERE `field`=
Comment on Bug Report
| Posted by: stanleyxu on 13 May 2008 7:37pm | |
|
|
Solution: Change Line 457 to if ($escape === TRUE OR $v === ‘’ OR $v === NULL) |
| Posted by: nicovv on 14 May 2008 5:36am | |
|
|
Yes, I encountered the same bug, but the fix is OK! |
| Posted by: Derek Allard on 14 May 2008 6:34am | |
|
|
This doesn’t strike me as a bug at all. CodeIgniter is comparing “field” against what yo asked it to compare against… which is nothing. If I wanted to test for it that way I’d probably use
$this->db->where('field','""', FALSE); |
| Posted by: stanleyxu on 14 May 2008 7:42am | |
|
|
Actually my code is: $fields = explode(’,’, $csv_line); // $csv_line = “0,,2” In previous version, fields[1] would be translated as “‘’”. Hi Derek, can you say it is not a bug? |
| Posted by: Derek Allard on 14 May 2008 7:59am | |
|
|
I concede that earlier versions may have parsed it differently. Behaviour was changed due to another bug report. This being discussed in http://codeigniter.com/forums/viewthread/79423/. Let’s continue the discussion there, and if warranted we’ll re-open this. |
