Welcome Guest, Not a member yet? Register   Sign In
Hooking / modifying database connections?
#1

[eluser]degu[/eluser]
Hello,

is there a good way to execute code directly after the database library has established a database connection?

Background: CodeIgniter assumes that double quotes (") are a good way to quote identifiers in sql queries for MS SQL Server (see _protect_identifiers in mssql_driver.php). This doesn't always work, as SQL Server's way of quoting identifier is to use brackets like this:

Quote:SELECT * FROM [tablename]

Anyway, in order to tell MS SQL Server to understand double quotes, one has to execute a query to configure the database connection like this:

Quote:$CI->db->simple_query('SET QUOTED_IDENTIFIER ON');

Now the question is where would be the best way in an application to execute this code? I would like to auto load the db library and already tried to use the post_controller_constructor hook to execute the above code, but it looks like this might be to late.

Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB