내 CMS에서 데이터베이스에 테이블을 생성하여 모듈을 추가하려고합니다. 그러나 CodeMiter를 사용하는 Codeigniter에는 하나의 필수 규칙이 있습니다. 코드에 tablename을 지정하십시오. 다음과 같이 Datamapper 모델을 만들었습니다.Codeigniter Datamapper - __construct에 의한 tablename 추가
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;
}
}
이름이 'module_universeel'인 테이블을 만들 때 작동합니다. tablename을 'module_news'또는 다른 것으로 변경하면 작동합니다. 하지만 그것은 내 datamapper의 구조 ($ this-> fields)를 변경하지 않습니다.
어떻게하면됩니까? 아무도이 경험이 있습니까? this->fields
배열이 parent::__construct();
에 그리고 그 시점에서 채워집니다
그 중 하나가 작동하지 않습니다. 내 테이블의 이름은 변경되지 않습니다 (인쇄 할 때). – DutchDeveloper
모델을 어떻게 부르십니까? – Geert