Welcome Guest, Not a member yet? Register   Sign In
Model calling success in controller, but i cannot use any item in model
#1

[eluser]Önder ÖZCAN[/eluser]
My Model is

Code:
class Content_list  extends CI_Model
{
        function __construct()
        {
           // Call the Model constructor
            parent::__construct();
        }
        
        public function  getContents()
        {
            $data['query'] = $this->db
            ->select('cat.catName')
            ->select('cat.cat_ID')
            ->select('cat.language')        
            ->select('con.category_ID')
            ->select('con.content_ID')
            ->select('con.content_ID')
            ->select('con.lastUpdated')
            ->from('content con')
            ->from('category cat')        
            ->where('con.category_ID' , 'cat.cat_ID')
            ->where('userPassword' , $password)
            ->where('userEnabled' , 'true')        
            ->get();
            
            if($data['query']->num_rows() == 0) {
                $this->session->set_flashdata('message', 'Sistemde ekli bir içerik bulunmamıştır.');
                redirect('login');
                return;
            }
        }
}

And my controller looking like that

Code:
class  admin  extends CI_Controller
{
      public function  __construct()
      {
         parent::__construct();
         $this->load->model('content_list');
         $this->publicData = array();
         $this->publicData['username'] = $this->session->userdata('username');
         $this->Content_list->getContents();
         $this->publicData['query'] = $this ->Content_list->data['query'];
     }      
     public function index()
     {

         $this->load->view('admin/index',  $this->publicData);
          
     }
}

The output gives error like that :

Severity: Notice

Message: Undefined property: admin::$Content_list

Filename: controllers/admin.php

Line Number: 15

Fatal error: Call to a member function getContents() on a non-object in /Applications/MAMP/htdocs/mediaworks/application/controllers/admin.php on line 15

My all database, session and other libraries and helper had added on autoload config. The problem is , CI cannot find the proper object in model even if i call the model correct.

Can anyone tell me where was i wrong ?
#2

[eluser]Önder ÖZCAN[/eluser]
Oh i just found what i got missed ,

When u calling your model , model name should be lowercase and filename should be same also . But class name in model should be first name Captial rest of lower case.

According to CI official docs, when you calling your model with lowercase and when you use it $this->Captial_model->func(); . It means when you calling some objects in your model, model name should be same as class name . But things now going like that , i tried and tried several hours to fix Object fatal error due to capital name staff but i realize also when you calling your model object, model name should be lowercase !

Thank you CI for wasting our time and keep trolling people .. Asap I was good with Yii i will drop to use this shitty Framework !!!




Theme © iAndrew 2016 - Forum software by © MyBB