Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7634309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:08:16+00:00 2026-05-31T07:08:16+00:00

In the index file i have _autoload and load the libs and then i

  • 0

In the index file i have _autoload and load the libs and then i explode the url to get the wanted contoller and the model if exists. In the view i can see the model __construct() so the model is loaded but if i try to use $this->model->test(); i get

Call to a member function test() on a non-object

http://site.com/about

$this->request = about;
$controller = new $this->request;
$controller->loadModel($this->request); 

Everething work ok

*Here is the Main controller *

class Conroller  {

    function __construct() {
        // echo 'Main controller<br />';
        $this->view = new View();
    }

    public function loadModel($name) {
        $path = 'models/'.$name.'_model.php';
        if (file_exists($path)) {
            require 'models/'.$name.'_model.php';
            $modelName = $name . '_model';
            // **here i make the object** 
            $this->model = new $modelName();
        }       
    }

}

Here is the About model

class about_model{

    function __construct() {
        echo 'test';
    }

    public function test() {
        $test = 'test one';
    }

}

Here is the About Conroller

class About extends Conroller {

   function __construct(){
       parent::__construct();
       $this->model->test();
       $this->view->render('/about');
   }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:08:18+00:00Added an answer on May 31, 2026 at 7:08 am

    You will need to call loadModel in your About controller before you refer to the model:

    class About extends Conroller {
    
       function __construct(){
    
         parent::__construct();
    
         $this->loadModel('about');
         $this->about->test();
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my index view file i have: $this->widget('zii.widgets.CListView', array( 'dataProvider'=>$dataProvider, 'itemView'=>'_view', 'ajaxUpdate'=>false, )); A
I have this code in index.html file: $(function(){ $('a#link').live('click', function(e){ $(div#element).load(file.html); }); }); In
I have such folder structure in my django site theme: index file load the
I have a index.py file which imports a few modules. I later import my
I have a index.php file which loads (require) 2 different files based on a
I have an index.php file which has 2 included files require(stats.php); require(stats_encry.php); stats.php which
I have a index.php file that will include several external files: content/templates/id1/template.php content/templates/id2/template.php content/templates/id3/template.php
If I have three files index.php file.php and fns.php First example (it works): index.php
I have a PHP script (index.php) that includes an index.html file in a sub-directory
I have Javascript function defined in the main index.html file. One part of this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.