PDO如何从表中获取auto_increment值

时间:2015-11-28 19:52:52

标签: php mysql pdo last-insert-id

我在php中创建日历并从数据库中获取事件。我们还必须使用准备好的PDO语句插入事件。我可以成功创建新事件并将其插入到事件表中。我还必须与家人联系和活动。

$stmt = $handle->prepare("INSERT INTO events(name, description, starthour, meridian, eventdate)
  VALUES(:name, :description, :starthour, :meridian, :eventdate)");
$stmt->execute(array(
    "name" => $name,
    "description" => $description,
    "starthour" => "$starthour",
    "meridian" => "$meridian",
    "eventdate" => "$eventdate"
 ));

$stmt1 = $handle->prepare("INSERT INTO familymemberevents(familymemberID,eventID)
    VALUES(:familymemberID, :eventID)");
$stmt1->execute(array(
    "familymemberID" => $familymemberid,
    "eventID" => 
));

eventID自动递增。无论如何,我可以从数据库中获取此号码吗? 提前致谢!

1 个答案:

答案 0 :(得分:1)

var beast = monsterArray;