datamapper 객체를 하나씩 할당하는 대신 모든 속성을 자동/동적으로 설정할 수 있습니까?Codeigniter Datamapper는 Post 데이터의 객체 속성을 설정합니다.
그래서 내 양식 필드 이름은 datamapper 모델의 속성과 완전히 동일합니다.
그래서이 작업을 수행하는 짧은 방법이 있습니다 :
function add() {
if($this->input->post('client-add')) {
$c = new Client();
$c->name = $this->input->post('name');
$c->email = $this->input->post('email');
// and so on for about 20 more properties
$c->save();
}}
코드 헬터 datamapper에서 배열 도우미를 설치하는 것으로 끝나고 $ c = from_array ($ this-> input-> post()); $ c-> save(); – Simon