Tutorial by Examples

Go to application/model File name - Home_model.php Inside the file class Home_model extends CI_Model { public $variable; public function __construct() { parent::__construct(); } public function get_data() { $query = $this->db->get('tabl...
Syntax - $this->load->model('model_name'); Practice - $this->load->model('home_model'); If you would like your model assigned to a different object name you can specify it via the second parameter of the loading method: Syntax - $this->load->model('model_name', 'foobar'); ...
Syntax $this->load->model('model_name'); $this->model_name->method_name(); Practice $this->load->model('home_model'); $this->home_model->get_data();
Syntax $array = array( '' => , ); # can pass array $singelData = ''; # something just a filed value $this->load->model('model_name'); $this->model_name->method_name($singelData, $array); Practice $array = array( 'name' => 'codeigniter', 'version' =&g...
public function method_name($single, $array) { echo $single; print_r($array); } Beware with the order which pass from controller to model.
public function get_username($uid) { $query = $this->db->select('id') ->select('name') ->from('user_table') ->where('id', $uid) ->get(); return $query->result_array(); } this will re...

Page 1 of 1