CodeIgniter Forums

Full Version: Query builder escaping periods when using TableName.Column
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

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:
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!
Did you try using single quotes?
"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.
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!
No problem were here to help if we can.