• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[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, 05: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
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 the CodeIgniter Community in 2009.          ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.