HMVC |
[eluser][email protected][/eluser]
Hi I realize that the problems comes when i try to access model like these way $this->load->model('mdl_users'); that is where its get stuck show error Fatal error: Class 'Mdl_users' not found in C:\xampp\htdocs\csir_pri_cms\application\third_party\MX\Loader.php on line 209
[eluser]Tim Brownlaw[/eluser]
if you have a module called "users" with the following structure modules users controllers users.php admin.php models mdl_users.php To load the model mdl_users from the users module, try using the <module name>/<model filename>, ie $this->load->model('users/mdl_users'); To load the users controller you can use $this->load->module('users/users'); But since the controller has the same name as the module you can shorten it to just. $this->load->module('users'); To load the admin module you would use $this->load->module('users/admin'); What I do, If I want to access a Model from another module, is create a method inside the modules controller to perform the call. So All external access is done through a controller call. Which means I only need to load the module like $this->load->module('funky_stuff") and use this $this->funky_stuff-><method_name> and never have to know about any underlying models etc.
[eluser][email protected][/eluser]
i try this $this->load->model(‘mdl_users’); is not working
[eluser]Tim Brownlaw[/eluser]
[quote author="[email protected]" date="1406115599"]i try this $this->load->model(‘mdl_users’); is not working[/quote] That will work if you have that file, mdl_users.php, in application/models/mdl_users.php. Is the class in that file written as ... class Mdl_users ...... and the filename in all lower case? Also where does mdl_users.php actually live?
[eluser][email protected][/eluser]
Hi Here is a model code as requested <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Mdl_uers extends CI_Model { function __construct() { parent::__construct(); } function get_table() { $table = "users"; return $table; } function password_check($username, $password){ $table = $this->get_table(); $this->db->where('username', $username); $this->db->where('password', $password); $query=$this->db->get($table); $num_rows = $query->num_rows(); if($num_rows>0){ return TRUE; }else{ return FALSE; } } function get($order_by){ $table = $this->get_table(); $this->db->order_by($order_by); $query=$this->db->get($table); return $query; } function get_with_limit($limit, $offset, $order_by) { $table = $this->get_table(); $this->db->limit($limit, $offset); $this->db->order_by($order_by); $query=$this->db->get($table); return $query; } function get_where($id){ $table = $this->get_table(); $this->db->where('id', $id); $query=$this->db->get($table); return $query; } function get_where_custom($col, $value) { $table = $this->get_table(); $this->db->where($col, $value); $query=$this->db->get($table); return $query; } function _insert($data){ $table = $this->get_table(); $this->db->insert($table, $data); } function _update($id, $data){ $table = $this->get_table(); $this->db->where('id', $id); $this->db->update($table, $data); } function _delete($id){ $table = $this->get_table(); $this->db->where('id', $id); $this->db->delete($table); } function count_where($column, $value) { $table = $this->get_table(); $this->db->where($column, $value); $query=$this->db->get($table); $num_rows = $query->num_rows(); return $num_rows; } function count_all() { $table = $this->get_table(); $query=$this->db->get($table); $num_rows = $query->num_rows(); return $num_rows; } function get_max() { $table = $this->get_table(); $this->db->select_max('id'); $query = $this->db->get($table); $row=$query->row(); $id=$row->id; return $id; } function _custom_query($mysql_query) { $query = $this->db->query($mysql_query); return $query; } }
[eluser]Tim Brownlaw[/eluser]
I spy with my little eye, something missing an 's' Code: class Mdl_uers extends CI_Model { Code: class Mdl_users extends CI_Model { If something don't work - check for typos - sometimes it takes fresh eyes to see these things
|
Welcome Guest, Not a member yet? Register Sign In |