【发布时间】:2012-11-23 21:07:55
【问题描述】:
$insert = "INSERT INTO event_tracker_table (event_name, event_location, location_number, event_creator_username, event_creator_email)
VALUES (
'".$_POST['event_name']."',
'".$_POST['event_location']."',
'".$_POST['location_number']."',
'".phpCAS::getAttribute('uid')."',
'".phpCAS::getAttribute('mail')."'
)";
$mysqli->query($insert);
我如何获得这个由 MySQL 生成的 AUTO INCREMENT?我试过了,但它不起作用:
$statement = $mysqli->query($insert);
echo $statement->insert_id;
【问题讨论】:
-
@Pekka 自动增量主 ID 的名称是“eventid”
-
@E_p 我没有使用 pdo,我使用的是 mysqli...请阅读问题
-
你想要
$mysqli->insert_id -
不,您使用的是
$statement_insert_id