CodeIgniter Forums
[v2] - getting Undefined property with model - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 2.x (https://forum.codeigniter.com/forumdisplay.php?fid=18)
+--- Thread: [v2] - getting Undefined property with model (/showthread.php?tid=1421)



[v2] - getting Undefined property with model - Krycek - 03-09-2015

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 ?


RE: [v2] - getting Undefined property with model - CroNiX - 03-09-2015

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.



RE: [v2] - getting Undefined property with model - Krycek - 03-09-2015

(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.