In my CMS I want to add modules by creating a table in the database. But Codeigniter with datamappers has one mandatory rule: give the tablename in your code. I have create a Datamapper model as following:
class Module_universeel extends DataMapper {
public $table = 'module_universeel';
public $has_one = array('page');
public function __construct($module_table=null) {
parent::__construct();
if(isset($module_table)) $this->table = $module_table;
}
}
This works when I create a table with the name: 'module_universeel'. When I change the tablename into 'module_news' or something, it works. But it doesn't change the structure ($this->fields) of my datamapper.
How can I do this? Does anybody have experience with this?