Create functions in the model in Codeigniter
Delete, Fetch, Insert and Update functions in Codeigniter
<?php
class Customer_model extends CI_Model {
/**
* Responsable for auto load the database
* @return void
*/
public function __construct()
{
$this->load->database();
$this->load->helper('url');
}
/**
* Get product by his is
* @param int $product_id
* @return array
*/
public function get_login_data()
{
$this->db->select('*');
$this->db->from('login_form');
$query = $this->db->get();
return $query->result_array();
}
public function login_detail($email,$password)
{
$this->db->select('*');
$this->db->from('login_form');
$this->db->where('email',$email);
$this->db->where('password',$password);
$query = $this->db->get();
return $query->result_array();
}
public function get_single_user_detail($user_id)
{
$this->db->select('*');
$this->db->from('login_form');
$this->db->where('ID',$user_id);
$query = $this->db->get();
return $query->result_array();
}
function register_user($name,$phone,$email,$password){
$data = array(
'name' => $name,
'phone' => $phone,
'email ' => $email,
'password ' => $password
);
$this->db->insert('login_form', $data);
}
function delete_user($user_id){
$this -> db -> where('ID', $user_id);
$this -> db -> delete('login_form');
}
function update_user($user_id,$name,$phone,$email,$password){
$data = array(
'name' => $name,
'phone' => $phone,
'email ' => $email,
'password ' => $password
);
$this->db->update('login_form', $data);
$this -> db -> where('ID', $user_id);
}
}
Comments
Post a Comment