本文整理匯總了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;
}