Welcome Guest, Not a member yet? Register   Sign In
Can you close the default database groupd
#3

(05-20-2016, 02:01 AM)Narf Wrote: You are indeed closing the connection, but if you try to use it again (which you do via dbutil) the database class will re-open it.

'pconnect' has no relation to this.

Thanks for the reply, so dbutil will open the default(active_group) connection even after I have executed:

Code:
$this->load->database('other_db_group');

Because I loaded and use the dbutil after executing the above line. From what I have read in the documentation I interpreted the above line to mean "If you specify the db_group as the first parameter it becomes the default connection hence you can use:

Code:
$this->load->dbutil();


 to refer to it instead of manually specifying:

Code:
$this->myutil = $this->load->dbutil($this->other_db_group,TRUE);

Likewise it leads me to believe that if perform the connect in this manner:

Code:
$this->load->database('other_db_group');


 you can also use, the default db object like this:

Code:
$this->db->query($sql);

and it will be querying the other_db_group database instead of the default(active_group).

I took a break from writing this post and modify the code to not call the dbutil at all so it has no chance of reconnecting to the old db_group. As you stated:

Quote:You are indeed closing the connection, but if you try to use it again (which you do via dbutil) the database class will re-open it.

'pconnect' has no relation to this.

so if I don't use the dbutil there should be no chance of it reconnecting.

However I still received the following error:
PHP Code:
A PHP Error was encountered

Severity
Warning

Message
pg_query(): Query failedERRORrelation "some_table" does not exist LINE 1: ...field1 as namefield2 as balance from some_table wher... ^

Filenamepostgre/postgre_driver.php

Line Number
242

Backtrace
:

File: /home/user/lappstack-5.6.20-1/apps/myapp/application/models/testlogin/Some_table_model.php
Line
31
Function: query

File
: /home/user/lappstack-5.6.20-1/apps/myapp/application/controllers/Some_table_controller.php
Line
64
Function: get_balance

File
: /home/user/lappstack-5.6.20-1/apps/myapp/application/controllers/Some_table_controller.php
Line
48
Function: get_balance

File
: /home/user/lappstack-5.6.20-1/apps/myapp/htdocs/index.php
Line
315
Function: require_once 

I have replace the file names, table name, field name and directory paths with random info as the info I have is fragile.

A co-worker of mind told me in the same stack overflow link I have in my original post someone stated its an error with the database persistent in mysql and told me it might be the same with mine. I believe I am spending too much time on this issue I already have a solution to use multiple db connection. I was just trying to see if you can use just one db connection (for possible resource management) but it doesn't seem to work. I will just use multiple database connection.

Thanks for the assistance none the less

jerg
Reply


Messages In This Thread
RE: Can you close the default database groupd - by jerg - 05-20-2016, 07:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB