• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Query builder escaping periods when using TableName.Column

#1
Hey!

In my query, I'm using the "TableName.ColumnName" syntax to designate a specific column.
Unfortunately, when using the query builder, the period in those parts is getting escaped, forming the following:
"`TableName`.`ColumnName`"
Which obviously throws a SQL Error.

Is there a way to solve this other than turning off QueryBuilder's "automatic SQL Injection prevention" (Which is pretty much my top reason for using Query Builder. Otherwise I could just build the query string on my own.)?
(The solution of turning off QueryBuilder's automatic escaping was posted on StackOverflow)

Thank you very much!
Reply

#2
Did you try using single quotes?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
"The period" isn't getting escaped, the table and field names are, and there's nothing wrong with that.

Chances are, on whatever database you're using, that causes it to treat identifiers in a case-sensitive manner, so you need to write them exactly as they are in the table definition.
Reply

#4
I'm sorry. It was actually completely my bad, and the problem was somewhere else in the query. The error message said "Field name unkown" and showed me the part of the query where the field names got escaped to "`Table`.`Field`", so I just assumed that MySQL does not accept such a format - Although the error was somewhere else.

I'm really sorry for uselessly taking your time like this. Still, thanks for the replies!
Reply

#5
No problem were here to help if we can.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.