Model of CodeIgniter Reviewed by Momizat on . A model notifies its associated views and controllers when there has been a change in its state. This notification allows the views to produce updated output, a A model notifies its associated views and controllers when there has been a change in its state. This notification allows the views to produce updated output, a Rating: 0

Model of CodeIgniter

A model notifies its associated views and controllers when there has been a change in its state. This notification allows the views to produce updated output, and the controllers to change the available set of commands.

<?php 
class User_model extends CI_Model
{
    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }
    function insertdata($tbl,$data)
    {
        $this->db->insert($tbl,$data);
    }
     
    function updatedata($tbl,$data,$fid,$fval)
    {       
        $this->db->update($tbl,$data, array($fid =>$fval));
    }
     
    function deletedata($tbl,$fid,$fval)
    {
        $this->db->delete($tbl, array($fid => $fval)); 
    }
     
    function getallusers()
{ 
	/*
$sql="select * from users";
$query = $this->db->query($sql);
return $rec=$query->result_array();
*/   
$this->db->select('*');
$this->db->from('users'); 
//$this->db->join('profile',"profile.userid=users.userid",'left');
//$this->db->where(array('userid'=>1));
//$this->db->where_in("userid",array('12','23','5'));
//$this->db->order_by("username", "asc");
//$this->db->group_by(array("userid")); 
$query = $this->db->get(); 
//$result=$query->row_array();  
//$query->num_rows();		
$result=$query->result_array();
return $result;
    }
}
?>

Leave a Comment

© 2014 Powered By