Модель:
Код: Выделить всё
public function edit_profile($array)
{
$email = $array['email'];
$this->db->select("email");
$this->db->from("user");
$this->db->where('email', $email);
$query=$this->db->get();
if ($query->num_rows() == 1) {
$this->db->update('user', $array);
return 1;
} else {
return $query->num_rows();
}
}
Код: Выделить всё
public function edit()
{
$name = $this->input->post('user_name', TRUE);
$email = trim($this->session->userdata('email'));
$array = array('user_name' => $name, 'email' => $email);
$result = $this->edit_profile_model->edit_profile($array);
echo $result;
}
Как обновить определенную строку?
Почему $query->num_rows() возвращает 1 и обновляет все строки?
Подробнее здесь: https://stackoverflow.com/questions/220 ... ith-the-sa
Мобильная версия