Это в моей модели.
Моя ошибка говорит:
Объект класса CI_DB_mysql_result не может быть преобразован в int
Проблема в select_max('id'), и он всегда возвращает 1.
public function addEstablishment()
{
$capacity = $this->input->post('capacity');
$name = $this->input->post('name');
$curfew = $this->input->post('curfew');
$price = $this->input->post('price');
$gender = $this->input->post('gender');
$type = $this->input->post('type');
$this->db->select_max('id');
$result = $this->db->get('establishment');
$query = $result + 1;
$owner = $this->session->userdata('id');
$data = array(
'id' => $query,
'name' => $name ,
'capacity' => $capacity ,
'curfew' => $curfew ,
'gender' => $gender ,
'type' => $type ,
'owner' => $owner
);
if ($this->db->insert('establishment', $data))
{
echo "Successfully added";
}
}
Подробнее здесь: https://stackoverflow.com/questions/245 ... in-codeign
Мобильная версия