php - Switching databases in code igniter -



php - Switching databases in code igniter -

i have 2 databases need connect to, can in controllers , libraries have written. odd reason (i'm assuming i'm missing simple here) can't work in model of sudden. have read database class in ci user guide.

i tried making reference $pew when loading pew ($this->pew =& $this->load->database('pew', true)) no avail.

any thoughts, suggestions? thanks!

error

php fatal error: phone call fellow member function query() on non-object in /sites/ci/nyan/application/models/pewpewmodel.php on line 15

line 15

$this->pew->query('select * extractevent'); //simplified testing

database.php:

$active_group = 'nyan'; $active_record = true; $db['nyan']['hostname'] = 'catcatcat'; $db['nyan']['username'] = 'mew'; $db['nyan']['password'] = 'meow'; $db['nyan']['database'] = 'meow'; $db['nyan']['dbdriver'] = 'mysql'; $db['pew']['hostname'] = 'jujubees'; $db['pew']['username'] = 'qwop'; $db['pew']['password'] = 'qwop'; $db['pew']['database'] = 'nom'; $db['pew']['dbdriver'] = 'mssql';

model pewpewmodel.php

private $pew; function __construct() { parent::__construct(); $this->pew = $this->load->database('pew', true); } function get_forms_by_date($id = null, $year = null, $month = null, $day = null) { $this->pew->query('select * extractevent'); //simplified testing }

controller nomnom.php

public function index() { $this->load->model('pewmodel'); $data['forms'] = $this->pewmodel->get_forms_by_date($this->session->userdata('username'), date('y'), date('n'), date('j')); $this->load->view('common/header', $data['forms']); $this->load->view('home/index'); $this->load->view('common/footer'); }

view index.php

<pre> <?php print_r($forms); ?> </pre>

$this->pew = $this->load->database('pew', true);

you load database doesn't exist in database-configuration.

php database codeigniter switching

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -