[eluser]Rahi[/eluser]
@summery and @nortrum
Thanks for your reply. I have gone through this before I created Model and Controller. I have just found what was wrong. If you see my controller I had implemented multiple databases(same what you suggested from documentation). Now I just moved those object to model and now everything is fine.
Controller
Code:
class Team_Users extends Controller {
public function __construct(){
parent:: __construct();
$this->load->model("team_users_model", "team");
}
public function get_team_users(){
$where =array("active"=>1);
$this->team->select_team_users($where);
// print("YESY");
var_dump(MY_Model::$destinationDBObj);
}
}
Model
Code:
abstract class MY_Model extends Model {
protected $table = ''; // table associated to the model
protected $fields = array(); // fields of table associated to the model
protected $tablePrefix = "ih_";
protected static $sourceDBObj=null;
protected static $destinationDBObj=null;
/**
* Constructor
* @access protected
*/
protected function __construct() {
parent::Model();
self::$sourceDBObj = $this->load->database("db1", TRUE);
self::$destinationDBObj = $this->load->database("db2", TRUE);
// get CI superobject as a model property
$this->ci =& get_instance();
}
public function setTableData($table = 'default') {
if (self::$destinationDBObj->table_exists($table)) {
$this->table = $this->tablePrefix.$table;
$this->fields = self::$destinationDBObj->list_fields($this->table);
}
}
}