Это моя функция в модели:
Код: Выделить всё
public function editHotel($service_id)
{
$hotel_id = $this->getHotelByServiceId($service_id);
$hotel = array(
'rating_id' => $this->input->post('rating'),
'treatment_id' => $this->input->post('treatment'),
'nation_id' => $this->input->post('nation'),
'region_id' => $this->input->post('region'),
'city_id' => $this->input->post('city'),
'area_id' => $this->input->post('area'),
'address' => $this->input->post('address'),
'phone' => $this->input->post('phone'),
'fax' => $this->input->post('fax'),
'email' => $this->input->post('email'),
'site' => $this->input->post('site'),
'description_it' => $this->input->post('description_it'),
'description_en' => $this->input->post('description_en'),
'latitudine_google' => $this->input->post('latitudine_google'),
'longitudine_google' => $this->input->post('longitudine_google'),
'modified' => date('Y-m-d H:i:s'),
);
$this->db->where('service_id', $service_id);
$this->db->update('hotel',$hotel);
}
Код: Выделить всё
public function editDescriptionHotel($service_id)
{
$hotel_id = $this->getHotelByServiceId($service_id);
$hotel = array(
'description_it' => $this->input->post('description_it'),
'description_en' => $this->input->post('description_en'),
'modified' => date('Y-m-d H:i:s'),
);
$this->db->where('service_id', $service_id);
$this->db->update('hotel', $hotel);
}
Если я использую функцию editHotel() для всех отправок, то любое неотправленное поле в таблице изменится на 0 или NULL.
Можно ли обновлять только те поля, которые я публикую?
Я не хочу писать новую модель метод для каждого отдельного представления.
Подробнее здесь: https://stackoverflow.com/questions/149 ... -sized-upd
Мобильная версия