Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter how to connect multi database using database.php for first connection and Model for second connection
#11

[eluser]dev.bashar[/eluser]
Code:
<?php
class user_model extends CI_Model {
    
        public function test()
        {
        $specific['hostname'] = "localhost";
        $specific['username'] = "myusername";
        $specific['password'] = "mypassword";
        $specific['database'] = "mydatabase";
        $specific['dbdriver'] = "mysql";
        $specific['dbprefix'] = "";
        $specific['pconnect'] = FALSE;
        $specific['db_debug'] = TRUE;
        $specific['cache_on'] = FALSE;
        $specific['cachedir'] = "";
        $specific['char_set'] = "utf8";
        $specific['dbcollat'] = "utf8_general_ci";
        
        $this->load->database($specific);
        
        //get data
        $o = new db_user();
        $array = array();
        $o->where($array)->get();
        echo $num_rows = $o->result_count();
        }
}
?>

this is my test code

when i call function from controller


Code:
public function calldatabase()
{  
     $user_id = $this->user_model->test();
}


it's still connect with main database
and it's didn't print wrong database connections ...


can you help me please Smile


Messages In This Thread
CodeIgniter how to connect multi database using database.php for first connection and Model for second connection - by El Forum - 04-15-2012, 07:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB