-1

ユーザーがユーザー情報を更新できるように構文を書きましたが、問題が発生しています。テスト目的で、24 の user_id を構文にハードコードしましたが、user_id を動的にしたいと考えています。私の質問は、ユーザー ID を取得するにはどうすればよいですか? 以下の構文は機能します (フォーム検証はまだ追加していませんが、すぐに追加します) ユーザー データの更新に関しては、動的に ID を取得する必要があります。以下のsnytaxを見ると、どうすればそれを行うことができますか? みんな、ありがとう。

私のコントローラー

public function update_records(){

  $now = date("Y-m-d H:i:s");

  $form_data = array(
  'business' => $this->input->post('business'),
  'user_id' => $this->input->post('user_id'),
  'address' => $this->input->post('address'),
  'state' => $this->input->post('state'),
  'city' => $this->input->post('city'),
  'zip' => $this->input->post('zip'),
  'phone' => $this->input->post('phone'),
  'website' => $this->input->post('website'),
  'email' => $this->input->post('email'),
  'name' => $this->input->post('name'),
  'time' => $now
  );

  $this->load->model('Change_data');
  $this->Change_data->update_function_three($form_data); 

私のモデル

function update_function_three($formdata){
// How would I make '24' dynamic?  
$this->db->where('user_id', '24');
$this->db->update('business',$formdata);
} 
4

2 に答える 2

1

試す :

$this->db->where('user_id', $formdata['user_id']);
于 2013-10-03T12:59:41.563 に答える