<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
  
class user_model extends CI_Model {
 
    function __construct() {
        parent::__construct();
        $this->load->database();
    }
 
    function find($where) {
        //create query to connect contacts database
        $this->db->from('user');
        $this->db->where($where);
         
        //get query and processing
        $query = $this->db->get();
        if($query->num_rows() == 1) { 
            return $query->result(); //if data is true
        } else {
            return false; //if data is wrong
        }
    }
    
    function save($data,$where){
        $this->db->from('user');
        $this->db->where($where);
         
        //get query and processing
        $query = $this->db->get();
        if($query->num_rows() == 1) { 
            $this->db->where($where);
            $this->db->update('user',$data);
        } else {
            $data['id'] = '1';
            $this->db->insert('user', $data); 
        }
        return true;
    }
}