Part of the EllisLab Network

Bug Report

Active Record is eating one of my quotes

Date: 05/07/2008 Severity: Minor
Status: Resolved Reporter: a_z_
Version: 1.6.1
Keywords: Libraries, Database Class
Forum Thread: http://codeigniter.com/forums/viewthread/78818/

Description

I just upgraded to 1.6.1 and an active record query that was previously working is now failing in a strange way. 

My select statement has two DATE_FORMATs.  The first DATE_FORMAT turns out fine, but the second one is missing the quote before the format string.  This causes mysql to choke.

Turning off backticks by adding FALSE as the second parameter to the select function doesn’t help.

If I remove the comma from the format string the problem goes away.  It also seems to go away if the two format strings are different.  Even
if I just add a leading space to one of them!

Code Sample

$this->db->select("*,
DATE_FORMAT(endtime, ‘%b %d, %Y %l:%i %p’) as prettyend,
DATE_FORMAT(starttime, ‘%b %d, %Y %l:%i %p’) as prettystart"
);
$query = $this->db->get(’assignments’);

Expected Result

SELECT *, DATE_FORMAT(`endtime`, ‘%b %d, %Y %l:%i %p’) as prettyend, DATE_FORMAT(`starttime`, ‘%Y %l:%i %p’) as prettystart FROM (`assignments`)

Actual Result

SELECT *, DATE_FORMAT(`endtime`, ‘%b %d, %Y %l:%i %p’) as prettyend, DATE_FORMAT(`starttime`, %Y %l:%i %p’) as prettystart FROM (`assignments`)

Comment on Bug Report

Page 1 of 1 pages
Posted by: alxjvr on 8 May 2008 12:37am
alxjvr's avatar

hmm, seems to be working, what i did was to remove ‘select’ from the $ar_items array in line# 1645 of function _merge_cache(),

from:

$ar_items = array(’select’, ‘from’, ‘join’, ‘where’, ‘like’, ‘groupby’, ‘having’, ‘orderby’, ‘set’);

into:

$ar_items = array(’from’, ‘join’, ‘where’, ‘like’, ‘groupby’, ‘having’, ‘orderby’, ‘set’);

..

Posted by: Derek Allard on 8 May 2008 6:09am
Derek Allard's avatar

Believe this is related to http://codeigniter.com/bug_tracker/bug/3478/

Name:

Email:

Location:

URL:

Remember my personal information

Notify me of follow-up comments?