codeigniter で開発したサイトがあり、テーブルを編集する関数を作成したいのですが、異なるフィールドでテーブルを更新する 2 つのページがあります。これはモデル内の私の機能です:
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 が挿入されます 最初の関数「editHotel」のみを使用して、投稿したフィールドのみを更新することは可能ですか? すべてのフィールドではなく、ページにあるフィールドのみを更新する関数のみをすべてのページで使用したいと考えています。可能です?テーブルを更新するすべてのページで、テーブルの別の関数更新を書き込む必要はありません