本文整理汇总了PHP中comments::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP comments::insert方法的具体用法?PHP comments::insert怎么用?PHP comments::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comments
的用法示例。
在下文中一共展示了comments::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: new_comment
public function new_comment()
{
if (!isset($_SESSION['uid'])) {
echo 1;
return;
}
$type = $_POST['type'];
$post_id = $_POST['post_id'];
$author_id = $_SESSION['uid'];
$content = '';
if ($type == 1) {
$content = $_POST['content'];
} else {
if ($type == 2) {
if ($_FILES['file']['error'] > 0) {
echo 2;
return;
} else {
$arr = split('.', $_FILES['file']['name']);
$suffix = $arr[1];
$des = 'upload/' . time() . $suffix;
move_uploaded_file($_FILES['file']['tmp_name'], $des);
$content = $des;
}
}
}
$comment = new comments();
$suc = $comment->insert($type, $post_id, $author_id, $content);
echo $suc ? 0 : 1;
return;
}
示例2: new_post
public function new_post()
{
if (!isset($_SESSION['uid'])) {
echo 1;
return;
}
$forum_id = $_POST['forum_id'];
$author_id = $_SESSION['uid'];
$title = $_POST['title'];
$content = $_POST['content'];
$post = new posts();
$id = $post->insert($forum_id, $author_id, $title, $content);
if (!$id) {
echo 1;
return;
}
$comment = new comments();
$suc = $comment->insert($id, $author_id, $content);
echo $suc ? 0 : 1;
return;
}