public function actionIndex() { $IndexModel = new IndexModel(); $memcache = Yii::$app->cache; $now_time = date("i", time()); $bookname_pinyin = $_GET['bookname']; $article_id = $_GET['article_id']; if ($article_id == 'index') { $action = 'index'; } else { $action = 'content'; } if ($now_time % 10 == 0) { $memcache->delete('Directory_bookinfo_' . $bookname_pinyin); } if (empty($memcache->get('Directory_bookinfo_' . $bookname_pinyin))) { $bookinfo = new bookinfo(); $article = new article(); $book_info = $bookinfo->Get_bookinfo_pinyin($bookname_pinyin); if (empty($book_info)) { $this->redirect('/404.php', 404); } //如果本小说不存在 则跳转404页面 $article_info = $article->Get_All_Article_Id($book_info['id']); $memcache->set('Directory_bookinfo_' . $bookname_pinyin, $book_info); $memcache->set('Directory_articleinfo_' . $bookname_pinyin, $article_info); $memcache->set('Directory_articleid_' . $bookname_pinyin, $article_id); return $this->render($action, ['bookinfo' => $memcache->get('Directory_bookinfo_' . $bookname_pinyin), 'article_info' => $memcache->get('Directory_articleinfo_' . $bookname_pinyin), 'article_id' => $memcache->get('Directory_articleid_' . $bookname_pinyin)]); } else { return $this->render($action, ['bookinfo' => $memcache->get('Directory_bookinfo_' . $bookname_pinyin), 'article_info' => $memcache->get('Directory_articleinfo_' . $bookname_pinyin), 'article_id' => $memcache->get('Directory_articleid_' . $article_id)]); } }
public function add_click($bookid, $click) { $bookinfo_query = new bookinfo(); $bookinfo = $bookinfo_query->findOne($bookid); $bookinfo->click = $click + 1; $bookinfo->save(); }
public function actionIndex() { $bookinfo = new bookinfo(); $article = new article(); $Pinyin = new TransPinyin(); $update = new IndexModel(); $update = $update->Get_Now_update(); $Recommendation_Right = $bookinfo->Recommendation_Right(); $bookinfo_updata = $bookinfo->Home_New_Book_updata(); return $this->render('index', ['Now_Update' => $update, 'Home_Recommended' => $bookinfo, 'Pinyin' => $Pinyin, 'Recommendation_Right' => $Recommendation_Right, 'Home_New_Book_updata' => $bookinfo_updata]); }
public function actionIndex() { $keywords = $_GET['keyword']; $array = bookinfo::find()->andFilterWhere(['like', 'bookname', $keywords])->orwhere(['like', 'author', $keywords])->orwhere(['like', 'bookname_pinyin', $keywords])->asArray()->all(); //var_dump($array);exit; //$this->redirect('http://www.baidu.com'); 可跳转 return $this->render('index', ['keywords' => $keywords, 'search_result' => $array]); }
public function Class_Recommendation($class) { $bookinfo = new bookinfo(); $Class_Recommendation = $bookinfo->find()->andwhere(['Class_Recommendation' => 1, 'Class' => $class])->asArray()->all(); return $Class_Recommendation; }
public function Update_Book_Info($bookid, $article_last_id, $article_title) { $bookinfo = new bookinfo(); $article_last_updatetime = date("Y-m-d H:i:s", time()); $update = $bookinfo->findOne($bookid); $update->article_last_id = $article_last_id; $update->article_last_title = $article_title; $update->article_last_updatetime = $article_last_updatetime; return $update->save(); }
public function Get_Book_Id($bookname) { $bookinfo = new bookinfo(); $bookid = $bookinfo->find()->where(['bookname' => $bookname])->asArray()->One(); return $bookid['id']; }