我一直在为多家商店制作一个库存系统。将所有数据插入到一个表中
我们如何根据商店获得最后插入的id?
例如,3个人同时在不同的pc上卖股票,如果我们取最后插入的id,这个id将返回,我需要得到每个商店各自的id。
型号:
public function Save_buyer_info($buyer_information)
{
//$email= $this->session->userdata('email');
// print_r($buyer_information);
$this->db->insert('live_sale_buyers',$buyer_information);
return $insert_id = $this->db->insert_id();
}控制器:
public function submit_order()
{
//$data=$this->input->post();
$name = $this->input->post('txt_name');
$emailBuyer = $this->input->post('txt_email');
$number = $this->input->post('txt_number');
$address = $this->input->post('txt_address');
$username = $this->session->userdata('username');
$payMode = $this->input->post('payment_mode');
$email = $this->session->userdata('email'); // get shop id
$this->db->where('email', $email);
$activeUser = $this->db->get('live_sale_users');
$a = $activeUser->row_array();
$shopId = $a['shop_id'];
$buyer_information = array(
"name" => $name,
"email" => $emailBuyer,
"mobile" => $number,
"address" => $address,
"done_by" => $username,
"paymentmode" => $payMode,
'shop_id' => $shopId,
'shop_keeper_email' => $email
);
$buyer_id = $this->Query_Inventory->Save_buyer_info($buyer_information);
}表结构:

发布于 2021-02-05 18:09:18
登录时,获取商店名称或商店id,并将其存储在会话变量中。在获取最后插入的id时,获取会话商店id,并且还返回插入时的当前时间data.This将确保最后插入的id来自哪个商店以及哪个时间
https://stackoverflow.com/questions/66051103
复制相似问题