Yes it is possible. I can explain the logic and how you can solve this problem using the special main class for the codeigniter application.
/core/ Mapdm.php
.
class Mapdm {
private $map_fields = array();
function __construct($modelClass_name, $map_fields = array()){
$this->_model = new $modelClass_name();
$this->map_fields = $map_fields;
}
function __get($name){
if(isset($this->map_fields[$name])){
$name = $this->map_fields[$name];
}
return $this->_model->{$name};
}
function __set($name, $value){
if(isset($this->map_fields[$name])){
$name = $this->map_fields[$name];
}
return $this->_model->{$name} = $value;
}
function __call($name, $args){
return call_user_func_array(array($this->_model, $method), $args);
}
}
, , , . , .
. map_field_config.php( )
$config['mapfield'][{modelname}] = array ('fieldA'=>'real_fieldname', 'fieldB'=>'real_fieldname2');
class ControllerName extends CI_Controller{
function __construct(){
parent::__construct();
$mapfields = $this->config->item('mapfield', $mapfields);
$model_fields = $mapfields['mymodel'];
$this->mymodel = new Mapdm('mymodel');
}
function index(){
$records = $this->mymodel->get();
}
}
, , . - Datamapper . datamapper.