public function getBaiViet($catid, $count)
 {
     $postList = new PostList();
     $c = 0;
     foreach ($this->postList as $k => $v) {
         if ($v->getIdLoai() == $catid) {
             if ($v->getAnHien() == 1 || $v->getAnHien() == '1') {
                 $postList->addPost($v);
                 if ($c > $count - 1) {
                     break;
                 }
                 $c++;
             }
         }
     }
     return $postList;
 }
Example #2
0
 public function getTopPopularRead($count, $idLoai = null)
 {
     $sql = "SELECT * FROM `mk_post`";
     if ($idLoai) {
         $sql .= " WHERE `idLoai`=" . $idLoai . " AND `AnHien` = 1";
     } else {
         $sql .= "WHERE `AnHien` = 1";
     }
     $sql .= "  ORDER BY `SoLanXem` DESC LIMIT 0," . $count;
     $this->load->database();
     $query = $this->db->query($sql);
     $result = $query->result_array();
     $postList = new PostList();
     foreach ($result as $k => $v) {
         $post = new PostClass();
         $post->setIdPO($v['idPO']);
         $post->setIdCL($v['idCL']);
         $post->setIdLoai($v['idLoai']);
         $post->setIdSub($v['idSub']);
         $post->setTieuDe($v['TieuDe']);
         $post->setTieuDeKD($v['TieuDeKD']);
         $post->setTitle($v['Title']);
         $post->setDes($v['Des']);
         $post->setKeyword($v['Keyword']);
         $post->setTomTat($v['TomTat']);
         $post->setNoiDung($v['NoiDung']);
         $post->setUrlHinh($v['UrlHinh']);
         $post->setNgayDang($v['NgayDang']);
         $post->setAnHien($v['AnHien']);
         $post->setNoiBat($v['NoiBat']);
         $post->setSoLanXem($v['SoLanXem']);
         $post->setIdGroup($v['idGroup']);
         $postList->addPost($post);
     }
     $this->db->close();
     return $postList;
 }