我需要从最后一个插入中获取 story_id。我试过使用mysql_insert_id()
,但它似乎不适用于我的陈述。这是代码:
$stmt = $this->db->prepare("INSERT INTO active_stories (story_id, current_chapter, creator, cover_title, cover_img_name, create_date, last_update_date, story_tags, locked) VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param("issssssi",$zero, $creatorName,$storyTitle, $fileName, $createDate, $createDate, $themeTags, $zero);
$stmt->execute();
printf("Last inserted record has id %d\n", mysql_insert_id());
$stmt->close();