<?php

/**
 * @filename model_common.php 
 * @encoding UTF-8 
 * @author 邱伟平 
 * @copyright 连云港龙泽商务有限公司 
 * @datetime 2013-6-9  10:00:06
 * @version 1.0
 * @Description
 */
class Model_news extends CI_Model {

    protected $news_type = "(
            17, //
        )";

    public function common($data) {
        return $data;
    }

    /*
     * 24小时排行
     */

    public function hot_24($start, $num) {
        $begin = mktime(date("H"), 0, 0, date("m"), date("d") - 1, date("Y"));
        $begin = date('Y-m-d H:i:s', $begin);

        //     echo $begin ."</br>";
        return $this->hot($begin, $start, $num);
    }

    /*
     * 周排行
     */

    public function hot_week($start, $num) {
        $begin = mktime(0, 0, 0, date("m"), date('d') - date('w'), date("Y"));
        $begin = date('Y-m-d H:i:s', $begin);
        //  echo $begin;
        return $this->hot($begin, $start, $num);
    }

    /*
     * 月排行
     */

    public function hot_month($start, $num) {
        $begin = mktime(0, 0, 0, date("m"), 0, date("Y"));
        $begin = date('Y-m-d H:i:s', $begin);
        //    echo $begin;
        return $this->hot($begin, $start, $num);
    }

    /*
     * 有行号
     * 按点击次数排序
     */

    function hot($begin, $start, $num) {
        $sql = "select @row := @row +1 AS ROW ," .
                " article.id, article.title " .
                "from cms_article article " .
                " ,( SELECT @row :={$start} ) r " .
                " where article.publish_time > '{$begin}'" .
                " and state = '正常' " .
                " and menu_id in (117,118,127,129,130,134)" .
                " order by click desc" .
                " limit {$start},{$num}";
        return $this->db->query($sql)->result();
    }

    /**
     * 广告图片加载 
     */
    function advert() {
        $sql = "select * from cms_photo where menu_id =223 order by id limit 0,4";

        return $this->db->query($sql)->result();
    }

}

/* End of file : model_common.php */
