我正在尝试保存到数据库,如果它已经在数据库中,我希望忽略该帖子。这就是我目前保存它的方式。postid
必须是独一无二的。
public function save($type, $postid, $url, $author, $content)
{
$post = new Post;
$post->type = $type;
$post->postid = $postid;
$post->url = $url;
$post->author = $author;
$post->content = $content;
echo $post;
$post->save();
}