私は2つのテーブルを持っているCodeIgniterの
| request_id | item_id | quantity_requested |
request_tbl
はForeignKeyとしてitem_id
を持っています。 $quantity - $quantity_requested
でアイテムテーブルの数量項目を更新するにはどうすればいいですか?ユーザがcodeigniter
を使用してリクエストテーブルへリクエストを送信するとどうなりますか?
MyController.php
:
function outward_items($request_id){
$this->load->model('request');
$ord_id = $this->request->insert_request($requests);
$outward = array(
'quantity_left' => $this->input->post('quantity_left'),
'item_id' => $this->input->post('item_id'),
);
$cust_id = $this->request->insert_outward($outward);
$data['requests'] = $this->request->get_requests($request_id);
$data['main_content'] = 'backend/requests/requests';
$data['title'] = 'Outwards';
$this->load->view('includes/template', $data);
}
あなたはコントローラやモデルに精通しており、単にSQLクエリの助けが必要? – mrid
はい私はコントローラとモデルが必要です – turaco
なぜあなたはmysqlトリガを使用しないでください、それは簡単です – Bira