Active Record Join Multiple conditions #7

Closed
bitbucket-import opened this Issue Aug 19, 2011 · 4 comments

Comments

Projects
None yet
5 participants

If there is a JOIN with multiple conditions it does not escape everything

For example:
{{{

!php

->join('tasks', 'projects.id = tasks.project_id AND tasks.deleted=0', 'left')
}}}

does not add the table prefix to the condition tasks.deleted=0

kewix commented Aug 26, 2011

I have the same issue using postgre driver... please fix this one this a major bug !

Tim, thanks for addressing this issue. I think it might need some tweaking, or I am not implementing correctly. Using the above query as an example.

    $this->db->join('tasks', 'projects.id = tasks.project_id AND tasks.deleted=0', 'left')

will create a query string like

    LEFT JOIN `tasks` ON `projects`.`id` = `tasks`.`project_id` AND `tasks`.`deleted`=`0`

Protecting 0 causes a MySQL error. I'm not even sure if this type of case should be automatically handled in the join method. I would of course like it to be, but it might break some other case. For now, I'm just protecting identifiers long hand in the active record query itself, kind of like this post.

http://codeigniter.com/forums/viewthread/119846/#737096

Contributor

Dentxinho commented Jan 12, 2012

This issue is related to #758 and if properly fixed may replace the solution given on #759.
Line 331 should match breaklines and tabs too.

Contributor

philsturgeon commented Apr 26, 2012

This is being handled in #759.

@narfbg narfbg added a commit that referenced this issue Jun 11, 2012

@narfbg narfbg Add changelog entry for issue #7 c73df1d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment