<?php

class recommends_and_tips_model extends CI_Model
{

    function __construct()
    {
        parent::__construct();
        $this->HT = $this->load->database('INFORMATION', TRUE);
    }


    public function recommends_list($is_id)
    {
        $sql = "   SELECT 
                    ir.ir_id
                    ,ir.ir_is_id
                    ,ir.ir_keyword
                    ,ir.ir_name
                    ,ir.ir_pointer_is_id
                    ,ir.ir_pointer_it_id
                    ,ir.ir_rule
                    ,ir.ir_urls
                    ,ir.ir_datetime
                    ,ir.ir_sitecode
                 from infoRecommends ir
                  where 1=1
                  AND ir.ir_sitecode=?
                  AND ir.ir_is_id=?
                 ";
        $query = $this->HT->query($sql, array($this->config->item('site_code'), $is_id));
        //print_r($this->INFO->queries);
        return $query->result();
    }

    public function tips_detail($it_id)
    {
        $timestamp=time();
        $sql = "   SELECT TOP 1
                    it.it_id
                    ,it.it_title
                    ,it.it_expires
                    ,it.it_code
                    ,it.it_content
                    ,it.it_sitecode
                    ,it.it_datetime
                 from infoTips it
                  where 1=1
                  AND it.it_sitecode=?
                  AND it.it_id=?
                  AND it.it_expires>=?
                 ";
        $query = $this->HT->query($sql, array($this->config->item('site_code'), $it_id,$timestamp));
        //print_r($this->HT->queries);
        if ($query->num_rows() > 0) {
            $row = $query->row();
            return $row;
        } else {
            return FALSE;
        }
    }

}
