Welcome Guest, Not a member yet? Register   Sign In
Parentheses escaping within ActiveRecord
#1

[eluser]Unknown[/eluser]
I have to perform the following database query:

Code:
SELECT * FROM albums
WHERE artist_name = 'Bedrock'
AND album_name = 'Emerald (including Charlie May remix)'
which works within the mysql console.

I am using ActiveRecord within C.I.:
Code:
$q = $this->db->get_where('albums',array('artist_name'=>$artist, 'album_name'=>$album));

However the parentheses are automatically escaped before querying the database:
Code:
SELECT *
FROM (`albums`)
WHERE `artist_name` = 'Bedrock'
AND `album_name` = 'Emerald & # 4 0 ;including Charlie May remix& # 4 1 ;'
(EDIT: I have added spaces within the escaped characters, the forum converted them to their ASCII form)
....and nothing is returned

I have tried the C.I. wiki work around but still no success.

How can I query the database with field values that contain parenthesis?
Kind regards,
Stegre.
#2

[eluser]pickupman[/eluser]
change get_where() to the two separate ->get() and ->where(). $this->db->where() accepts an optional third parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks.




Theme © iAndrew 2016 - Forum software by © MyBB