0
この方法で行う必要があるデータベースの支払いテーブルに挿入したいと思います。 私が持っている支払いテーブルには、テーブルグループとメンバーにそれぞれ関連する外部キーとしてgroup_idとmember_idの両方が含まれています。 私がしたいことは、一度、 "pay"ボタンを押すと、各member_idに支払いテーブルの行として挿入する必要があります。 はここ反復的にdbに挿入
function paymember(){
$data= array();
$this->db->where('group_id',$this->input->post('group_id'));
$memberid = $this->db->get('member');
if ($memberid->num_rows() > 0) {
foreach ($memberid->result_array() as $row){
$data[] = $row;
}
}
}
私を助けてください..私は
public function create_action()
{
$this->_rules();
if ($this->form_validation->run() == FALSE) {
$this->create();
} else {
$this->load->model('Member_model');
$memberid = $this->Member_model->paymember();
foreach ($memberid->result_array() as $id){
$memberid[] = $id;
$data = array(
'group_id' => $this->input->post('group_id',TRUE),
'member_id' => $memberid,
'paid_by' => $this->input->post('paid_by',TRUE),
'from_date' => $this->input->post('from_date',TRUE),
'to_date' => $this->input->post('to_date',TRUE),
'amount' => $this->input->post('amount',TRUE),
'reference_number' => $this->input->post('reference_number',TRUE),
//'last_updated_by' => $this->input->post('last_updated_by',TRUE),
//'last_update_time' => $this->input->post('last_update_time',TRUE),
);
}
$this->Payment_model->insert($data);
$this->session->set_flashdata('message', 'Record Created Successfully!');
redirect(site_url('payment'));
}
}
を持っていると私は、コントローラに含まれてきたMember_modelである私のモデルに私のコード..私のコントローラで です。ありがとうございました。
'paymember()'は何も返されないようです。あなたのコードはすべてそこにありますか?また、 'member'テーブルから来るフィールドは何ですか? – DFriend