<?php
class Browse_model extends CI_Model {

  public function __construct() {
      $this->load->database();
    }
  //SELECT

  public function browse()
  {
    $date = date("Y-m-d");
    $query = $this->db->get_where('xi_browse',array('browse_date' => $date));
    return $query->num_rows();
  }

  public function browse_all()
  {
    $date = date("Y-m-d");
    $query = $this->db->get('xi_browse');
    return $query->num_rows();
  }

  public function is_have($ip)
  {
    $date = date("Y-m-d");
    $query = $this->db->get_where('xi_browse',array('browse_ip' => $ip,'browse_date' => $date));
    return $query->num_rows();
  }
  //INSERT
  public function add($ip) {
    $date = date("Y-m-d");
    $browse = array(
      'browse_ip' => $ip, 
      'browse_date' => $date,
    );

    $query = $this->db->insert('xi_browse',$browse);
    return $query;
  }
  //UPDATE
  //DELETE
}
?>