から単一の行を取得し、:CodeIgniterの
'user_id' => $query->row()->id
があります必要なものがすべて1つのデータであれば、foreachループなしでこれを行う方法はありますか?
完全なコードは次のとおりです。
$this->db->where('username', $this->input->post('username'));
$query = $this->db->get('members');
$data = array(
'first' => $this->input->post('first'),
'last' => $this->input->post('last'),
'email' => $this->input->post('email'),
'phone' => $this->input->post('phone'),
'address' => $this->input->post('address'),
'city' => $this->input->post('city'),
'state' => $this->input->post('state'),
'zip' => $this->input->post('zip'),
'comments' => $this->input->post('comments'),
'username' => $this->input->post('username'),
'user_id' => $query->row()->id
);
$this->db->insert('contact', $data);
コードは機能しますか? –
いいえ、非オブジェクトのプロパティを取得しようとしているというエラーが表示されます。 – sehummel
「メンバー」テーブルに必要な行が存在していますか? –