我有這個代碼,我想要做的是獲得主鍵最後插入到用戶表,然後把它放到庫表的外鍵。我不知道如何處理$ request或在這裏做什麼?獲得主鍵作爲外鍵放在其他表
public function register($request = array()) {
$data = array(
'user_name' => $request['username'],
'password' => $request['password'],
'email' => ($request['email'])
);
$data1 = array(
'user_id' => '5',// this is where I have to put the primary key from last table
'library_name' => $request['lib_name']
);
$this->model->insert('user', $data);
$this->model->insert('library', $data1);
$this->redirect('uploadSongs.php');
}
你有一個支持外鍵MySQL的存儲引擎? (InnoDB?) – Tobias 2012-07-11 12:02:54