CodeIgniter Forums
[newbie]Cannot load model - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10)
+--- Thread: [newbie]Cannot load model (/showthread.php?tid=68246)



[newbie]Cannot load model - pippuccio76 - 06-15-2017

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


RE: [newbie]Cannot load model - donpwinston - 06-15-2017

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

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


RE: [newbie]Cannot load model - Paradinight - 06-15-2017

(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


RE: [newbie]Cannot load model - InsiteFX - 06-16-2017

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


RE: [newbie]Cannot load model - InsiteFX - 03-08-2018

@codenair,

Do you see the date of these posts?