Welcome Guest, Not a member yet? Register   Sign In
[newbie]Cannot load model
#1

HI  , i try to load model in a controller function :

this is my function :

Code:
public function prova(){
     
       $this->load->model('user_model');
       $data['record']=$this
                       ->user_model
                       ->recupera();
                       
       $this->load->view('user/prova',$data);
     
     
   }


in models i have file called user_model.php :

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');


class User_model extends CI_Model {
 
 
     public $users_table;

     public function __construct(){
       
        parent::__construct();

           $this->load->database();
       
        $this->users_table = $this->config->item('users_table');
       
     }      
     
     
     

 
   function recupera(){
   
    $this->db->where('email', '[email protected]');
    $q = $this->db->get('user')->row();

     return $q;
   
 }
 
 
 
 
}
when i go to :

http://localhost/user_codeigniter/index.php/user/prova


this error appear :

An uncaught Exception was encountered
Type: RuntimeException
Message: Unable to locate the model you have specified: User_model


i do permission 755 to folder  . but the error is the same
Reply
#2

$this->load->model('user_model');

try $this->load->model('User_model');
Simpler is always better
Reply
#3

(06-15-2017, 04:49 PM)donpwinston Wrote: $this->load->model('user_model');

try $this->load->model('User_model');

$this->load->model('user_model'); <- is correct


The filename could be wrong: Change user_model.php to User_model.php
Reply
#4

(This post was last modified: 06-16-2017, 03:35 AM by InsiteFX.)

1)

PHP Code:
$q $this->db->get('user')->row();

// should be

$q $this->db->get($this->user_table)->row(); 

Also make sure that when you saved the user_model that it was saved with the
first letter capitalized.

User_model.php
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

@codenair,

Do you see the date of these posts?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB