Remove double quotes in codeigniter query Builder

Asked

Viewed 630 times

1

I am using the Codeigniter framework and every time I create a select with their Builder query, it puts double quotes on all columns and tables.

Ex: SELECT "ID", "NAME" FROM "STUDENT"

This ends up giving me problem, because I use 2 connections with database, oracle and pgsql. oracle works normally, already in pgsql returns me error.

I know that if I put the last parameter in my functions as false, it works, but I wonder if there is some global parameter to do this, or I’ll have to pass method by method the false ?

  • which version of the IC you are using?

2 answers

1


Use this line before your query (documentation here):

$this->db->_protect_identifiers = false;

For a global parameter in the file ./application/config/database.php (database configuration file), add a new element to the array of standard settings:

$db['default']['_protect_identifiers'] = false;

0

Codeigniter has a second parameter in the Builder query to prevent word escape, see this link with the documentation, but in short you can use something like this:

$this->db->select('campo', false)
  • I mean, I’m gonna have to keep putting false in all the parameters, there’s no place I can leave without by default ?

  • Unfortunately yes, I do not believe that there is a global configuration, because theoretically this is bad code practice, allows SQL Injection very easily. You can try to change directly within the framework in the Query Builder class, but I do not advise

Browser other questions tagged

You are not signed in. Login or sign up in order to post.