45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace app\common\model;
|
|
|
|
/**
|
|
* 小说模型
|
|
*/
|
|
class Novel extends Base{
|
|
|
|
|
|
public function addchapter($book,$chapter,$content) {
|
|
$data = array(
|
|
"articleid" => $book['bookid'],
|
|
"uid" => $uid,
|
|
"chaptername" => $chapter['chaptername'],
|
|
"status" => 3,
|
|
"create_time" => time(),
|
|
"update_time" => time(),
|
|
"size" => $chapter['size'],
|
|
"saleprice" => $chapter['saleprice'],
|
|
"isvip" => $chapter['isvip'],
|
|
"chaptertype" => $chapter['chaptertype'],
|
|
"chapterorder" => $chapter['chapterorder'],
|
|
"articlename" => $book["title"]
|
|
);
|
|
$result = db('chapter')->insert($data);
|
|
if($result){
|
|
$chapterid = db('chapter')->getLastInsID();
|
|
//更新小说章节内容
|
|
$ocontent['chapterid'] = $chapterid;
|
|
$ocontent['content'] = $content;
|
|
db("novel_content")->insert($ocontent);
|
|
|
|
//更新小说总字数 总章节数
|
|
$data = array(
|
|
'lastvolumeid'=>$chapterid,
|
|
'lastvolume'=>$chapter['chaptername'],
|
|
'chapters'=>$chapter['chapterorder'],
|
|
'size'=>array('exp', '`size`+'.$chapter['size'])
|
|
);
|
|
db('novel')->where(array('id'=>$book['bookid']))->update($data);
|
|
}
|
|
return true;
|
|
}
|
|
} |