Example #1
0
 function TakeArticleList($cid = 0, $skip = 0, $take = 10, $orderby = "adddate desc", $all = false)
 {
     global $yiqi_db;
     $categorydata = new Category();
     $exist = $categorydata->ExistCategory($cid);
     if ($exist == 1) {
         $cids = array($cid);
         $cids = array_merge($cids, $categorydata->GetSubCategoryIDs($cid));
         $cids = implode(',', $cids);
         if ($all) {
             return $yiqi_db->get_results(CheckSql("select * from yiqi_article where cid in ({$cids}) order by {$orderby} limit {$skip},{$take} "));
         } else {
             return $yiqi_db->get_results(CheckSql(sprintf("select * from yiqi_article where cid in ({$cids}) and adddate <= '%s' order by {$orderby} limit {$skip},{$take} ", date("Y-m-d H:i:s"))));
         }
     } else {
         if ($all) {
             return $yiqi_db->get_results(CheckSql("select * from yiqi_article order by {$orderby} limit {$skip},{$take}"));
         } else {
             return $yiqi_db->get_results(CheckSql(sprintf("select * from yiqi_article where adddate <= '%s' order by {$orderby} limit {$skip},{$take}", date("Y-m-d H:i:s"))));
         }
     }
 }