<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
	
/**
	 * 
	 */
	class Add_number_model extends CI_Model
	{
		
		function __construct()
		{
			parent::__construct();
		}

		function db_insert()
		{
			$fullname = $this->input->post('fullname');
			$number = $this->input->post('number');
				$sure = $this->db->where('number', $number);
				$sure = $this->db->get('contects');
				if($sure->num_rows() > 0){
					return 3;
				}else{
					$data =  array(
						'fullname' =>$fullname,
						'number' =>$number
					);

					$q = $this->db->insert('contects', $data);
					if($q){
						return 1;
					}else{
						return 2;
					}

				}
		}

		function get_all_num_count(){
			$q = $this->db->get('contects');
			if($q->num_rows() > 0){
				return $q->num_rows();
				// return $q->row();
			}else{
				return 0;
			}
		}
		function get_all(){
			$q = $this->db->get('contects');
			if($q->num_rows() > 0){
				// return $q->num_rows();
				return $q->result();
			}else{
				return 0;
			}
		}
	}	

?>