创建帖子后,其post id
是主键。如何获取此post id
并将其发布到日期时间数据库表及其表的引用键
if (isset($_POST['submit'])) {
global $post;
$post->user_id= $_SESSION['user_id'];
$post->post_created_date = strip_zeros_from_date(date("Y-m-d"));
$post->post_created_time = "int time ( void )";
if ($post->createpost()){
global $datetime;
$datetime->post_id = ??? ;
redirect_to('profile.php');
} else {
// Failure
echo 'failed';
}
}
答案 0 :(得分:0)
不知道您正在使用哪种技术,但假设createpost
方法返回创建的帖子信息,您可以执行以下操作:
if ($newPost = $post->createpost()){
global $datetime;
$datetime->post_id = $newPost['id'];
...