• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[v2] - getting Undefined property with model

#1
I have the following code which giving me Undefined property: Uploader::$mod_Photoalbums_model

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

class 
Uploader extends MY_Controller {
    public function 
__construct() {
        
parent::__construct();
        
        
$this->load->library('image_lib');
        
$this->load->library('qquploadedfilexhr');
        
$this->load->model('Uploader_model');
        
$this->load->model('Portfolio_model'); 
        
$this->load->model('mod_Photoalbums_model');
        }

        public function 
insertIntoDatabase($id$module$filename$thumbnail$folder) {
        
$result false;

        switch (
$module) {            
            case 
'portfolio_images':
                
//PORTFOLIO - IMAGES
                

                
$result $this->Portfolio_model->add_image($id$module$filename$thumbnail$folder);
                
                break;                
            case 
'photoalbums_images':
                
//PHOTOALBUM - IMAGES
                
                
$result $this->mod_Photoalbums_model->add_image($id$module$filename$thumbnail$folder);
                
                break;
            case 
'pages':
                
//PAGES > CONNECTIONS (tab3) > UPLOADS
                
                
$result $this->page_model->addUploadToDatabase($id$module$filenamenull$folder$this->upload_title$this->upload_desc);
                
                break;
        }
        
        return 
$result;
    }



Photoalbum Model > On filesystem the name is lowercase

PHP Code:
class mod_Photoalbums_model extends MY_Model {
    public function 
__construct() {
        
parent::__construct();
    }

//ETC ETC


Code:
Severity: Notice
Message:  Undefined property: Uploader::$mod_Photoalbums_model
Filename: controllers/uploader.php
Line Number: 188

Anyone ?
Reply

#2
Read the section of the userguide dealing with Model naming.
Quote:Where Model_name is the name of your class. Class names must have the first letter capitalized with the rest of the name lowercase. Make sure your class extends the base Model class.

The file name will be a lower case version of your class name.
Reply

#3
(03-09-2015, 08:35 AM)CroNiX Wrote: Read the section of the userguide dealing with Model naming.

Quote:Where Model_name is the name of your class. Class names must have the first letter capitalized with the rest of the name lowercase. Make sure your class extends the base Model class.

The file name will be a lower case version of your class name.

Yeah I known, but this is old code.
But I found it. In the __construct a library was loaded.
This was causing the problem.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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