这是我将日期插入数据库的代码。一切都很好,除了我无法获得 insert_id。
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$data_to_store = filter_input_array(INPUT_POST);
$db = getDbInstance();
$Stats = $db->insert ('images', $data_to_store);
$last_id = $db->insert_id();
if($Stats)
{
$_SESSION['success'] = "Record added successfully!";
header('location: index.php');
exit();
}
}
表明:
Fatal error: Uncaught Error: Call to undefined method MysqliDb::insert_id() in
我的数据库:
function getDbInstance() {
return new MysqliDb(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);
}
怎么了?