在我的模型我有以下函數返回的獲取記錄ID在Php最後插入的ID笨
function getLastInserted()
{
$query = $this->db->select("MAX(`UserID`)+1 as userid")->get("registeration");
return $query->result();
}
現在我想通過該ID來myController的備案插入現在
public function newregistration()
{
if ($this->form_validation->run())
{
$data = array(
'Name' => $this->input->post('Name'),
'MobileNo' => $this->input->post('MobileNo'),
'IMEINumber' => $this->input->post('IMEINumber'),
'City' => $this->input->post('City')
);
$this->adminmodel->insertregistration($data);
}
}
我想在控制器中訪問模型函數並在數據函數中傳遞記錄ID我該怎麼做?
你是什麼意思***現在我想通過該ID到mycontroller記錄插入*** –
你可以共享代碼插入註冊功能? – Naincy
公共函數newregistration() \t { \t \t \t 如果\t($這 - > form_validation->運行()) \t \t { \t \t \t $數據=陣列( \t \t \t '用戶ID'=> $這 - > adminmodel-> getLastInserted(), \t \t \t '名稱'=> $這個 - >輸入 - >交的( '姓名'), \t \t \t 'MobileNo' => $這個 - >輸入 - >後( 'MobileNo'), \t \t \t 'IMEINumber'=> $這個 - >輸入 - >後( 'IMEINumber'), \t \t \t '市'=> $此 - > input-> post('City') \t \t \t); \t \t \t $ this-> adminmodel-> insertregistration($ data); \t \t} \t \t \t \t \t} – Anil