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

class Misel_vendor_contacts_model extends Base_Model
{

	function __construct()
	{

		parent::__construct();
		$this->set_database('sealmis');
		$this->set_table('tblpur_contacts');
		$this->set_pk('userid');
		$this->set_log(false);
	}

	function count()
	{
		$data = array();
		
		$this->db->where($this->where);
		$this->db->or_like($this->like);

		$query = $this->db->get($this->schema.'.'.$this->table.' tbl');
	
		return $query->num_rows();
	}

	function get_list()
	{
		$this->db->select('tbl.*');
		// $this->db->select('ctc.email');
		// $this->db->join('tblpur_contacts ctc','ctc.userid=tbl.userid','left');
		
		if($this->where)
		$this->db->where($this->where);
		if($this->like)
		$this->db->or_like($this->like);
		
		foreach ($this->order_by as $key => $value)
		{
			$this->db->order_by($key, $value);
		}

		if (!$this->limit AND !$this->offset)
			$query = $this->db->get($this->schema.'.'.$this->table.' tbl');
		else
			$query = $this->db->get($this->schema.'.'.$this->table.' tbl',$this->limit,$this->offset);
		
        if($query->num_rows()>0)
		{
			return $query;
        
		}else
		{
			$query->free_result();
            return $query;
        }
	}

}
