我需要从最后一次插入中获取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();
答案 0 :(得分:5)