양식 제출시 데이터베이스에서 내 값을 업데이트하는 데 문제가 있습니다. E에서 정의되지 않은 메서드 Model_setting :: updateTheme()에 전화 : XAMPP \ \ htdocs를 \ CodeIgniter의-테마 \ 관리 \ 컨트롤러 \ 설정 \ setting.php에 나는 CodeIgniter는 내가 오류 치명적인 오류가 발생하고 2.20formigniter에서 데이터베이스 업데이트
사용 8 행
내가 보관하려고하는 것은 한 번 폼에 테마를 선택하면 설정 테이블 값이 업데이트되는 위치에 게시됩니다. 양식 제출시 변경되지 않습니다. 자동로드 된 form_validation lib 및 form helper가 있습니다.
모델
<?php
class Model_setting extends CI_Model {
public function updateTheme() {
$this->db->select('*');
$this->db->where('group', 'config');
$this->db->where('key', 'config_template');
$this->db->where('value', $this->input->post('config_template')); // Need to update theme row
$query = $this->db->update('setting');
}
}
보기
<form method="post" action="<?php echo $action;?>" role="form" class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label" for="input-template"><?php echo $entry_template; ?></label>
<div class="col-sm-10">
<select name="config_template" id="input-template" class="form-control">
<?php foreach ($templates as $template) { ?>
<?php if ($template == $config_template) { ?>
<option value="<?php echo $template; ?>" selected="selected"><?php echo $template; ?></option>
<?php } else { ?>
<option value="<?php echo $template; ?>"><?php echo $template; ?></option>
<?php } ?>
<?php } ?>
</select>
<br />
<img src="" alt="" id="template" class="img-thumbnail" />
</div>
</div>
<button type="submit" class="btn btn-md btn-primary">Save</button>
</form>
내가이 일을 가지고
public function index() {
$this->load->model('setting/model_setting');
$this->model_setting->updateTheme();
if(null !==($this->input->post('config_template'))) {
$data['config_template'] = $this->input->post('config_template');
} else {
$data['config_template'] = $this->theme->get('value'); // Auto loaded Library Theme
}
$data['templates'] = array();
$directories = glob(DIR_CATALOG . 'views/theme/*', GLOB_ONLYDIR);
foreach ($directories as $directory) {
$data['templates'][] = basename($directory);
}
$this->form_validation->set_rules('config_template', '', 'callback_validate');
if($this->form_validation->run()) {
redirect('setting/store');
} else {
$this->lang->load('setting/setting', 'english');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->lang->line('text_home'),
'href' => site_url('common/dashboard')
);
$data['breadcrumbs'][] = array(
'text' => $this->lang->line('heading_title'),
'href' => site_url('setting/setting')
);
$data['action'] = site_url('setting/setting');
$data['title'] = "Settings";
$data['entry_template'] = $this->lang->line('entry_template');
$data['header'] = $this->header($data);
$data['footer'] = $this->footer($data);
$this->load->view('setting/setting', $data);
}
}