Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14346

multiple databases connectivity

$
0
0
I have the following code in model to connect to another database.


PHP Code:
        $db_name $this->session->userdata('db_name');
        $this->anotherDb $this->load->database($db_nameTRUE); 

but if I try to query in another model using the anoterDb using the following:

PHP Code:
        $query=$this->anotherDb->query("SELECT fieldValue
                                 FROM settings
                                 WHERE fieldName ="
."'".$fieldName."'"
                                 )->row_array();
                      $fieldValue $query['fieldValue']; 

error:
Quote:Message: Undefined property: Users::$anotherDb

to remove this error I need to reconnect to above database "anotherDb" in every model.
How can I solve this?


How can I make some global variable to be used in every model?

Viewing all articles
Browse latest Browse all 14346

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>