我有問題,ION驗證庫上。我想編輯現有的組,當我嘗試D編輯我有這樣的錯誤:笨行()非對象
哪裏是錯誤的,我所有的探索和CI文檔,但一切看起來罰款。
Fatal error: Call to a member function row() on a non-object in /var/www/ci_balcanrent/beta/modules/user/controllers/user.php on line 603
下面是編輯功能的控制器:
//edit a group
function edit_group($id) {
// bail if no group id given
if (!$id || empty($id)) {
redirect('user', 'refresh');
}
$this->data['title'] = $this->lang->line('edit_group_title');
if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin()) {
redirect('user', 'refresh');
}
$group = $this->ion_auth->group($id)->row();
//validate form input
$this->form_validation->set_rules('group_name', $this->lang->line('edit_group_validation_name_label'), 'required|alpha_dash|xss_clean');
$this->form_validation->set_rules('group_description', $this->lang->line('edit_group_validation_desc_label'), 'xss_clean');
if (isset($_POST) && !empty($_POST)) {
if ($this->form_validation->run() === TRUE) {
$group_update = $this->ion_auth->update_group($id, $_POST['group_name'], $_POST['group_description']);
if ($group_update) {
$this->session->set_flashdata('success', $this->lang->line('edit_group_saved'));
} else {
$this->session->set_flashdata('error', $this->ion_auth->errors());
}
redirect("user", 'refresh');
}
}
//set the flash data error message if there is one
$this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('error')));
//pass the user to the view
$this->data['group'] = $group;
$this->data['group_name'] = array(
'name' => 'group_name',
'id' => 'group_name',
'type' => 'text',
'value' => $this->form_validation->set_value('group_name', $group->name),
);
$this->data['group_description'] = array(
'name' => 'group_description',
'id' => 'group_description',
'type' => 'text',
'value' => $this->form_validation->set_value('group_description', $group->description),
);
$this->template->build('auth/edit_group', $this->data);
}
603線$組= $這個 - > ion_auth->組($ ID) - >行();
型號:
/**
* group
*
* @return object
* @author Ben Edmunds
**/
public function group($id = NULL)
{
$this->trigger_events('group');
if (isset($id))
{
$this->db->where($this->tables['groups'].'.id', $id);
}
$this->limit(1);
return $this->groups();
}
查看:
<?php echo form_open(current_url());?>
<p>
<?php echo lang('create_group_name_label', 'group_name');?> <br />
<?php echo form_input($group_name);?>
</p>
<p>
<?php echo lang('edit_group_desc_label', 'description');?> <br />
<?php echo form_input($group_description);?>
</p>
<p><?php echo form_submit('submit', lang('edit_group_submit_btn'));?></p>
<?php echo form_close();?>
'$這 - > ion_auth->組($ ID) - >行();'這裏這類方法是'行()'? – som
http://ellislab.com/codeigniter/user-guide/database/results.html – Jony