<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Crontjob_model extends CI_Model
{
    protected $_table = TABLE_CRONTJOBS;

    public function __construct()
    {
        parent::__construct();
        date_default_timezone_set("Asia/Ho_Chi_Minh");
    }

    public function cmsCountAll($name = null)
    {
        $this->db->select('COUNT(*) AS totalResults');
        $this->db->from($this->_table);
        if ($name != null) {
            $this->db->like($this->_table . '.message', $name, 'both');
        }
        $query = $this->db->get();
        $result = $query->result_array();
        if ($result) {
            return $result[0]['totalResults'];
        } else {
            return 0;
        }
    }

    public function cmsGetPagination($record, $start, $name = null)
    {
        $this->db->select('*');
        $this->db->from($this->_table);
        if ($name != null) {
            $this->db->like($this->_table . '.message', $name, 'both');
        }
        $this->db->order_by($this->_table . '.id', 'desc');
        $this->db->limit($record, $start);
        $query = $this->db->get();
        return $query->result_array();
    }

}

/* End of file welcome.php */