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 7845855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:23:17+00:00 2026-06-02T17:23:17+00:00

Before I start just letting you know that I’m new to OOP programming so

  • 0

Before I start just letting you know that I’m new to OOP programming so take it easy on me.

I’m currently working on a PHP framework and I’ve been able to route my traffic through one entry point. This is the structure below..

index ----> bootstrap ----> router ----> controller

Here’s the main controller…

class controller {

protected $_model;
protected $_controller;
protected $_id;
protected $_view;

function __construct($controller,$model,$view,$id=NULL) {

    $this->_controller = $controller;
    $this->_id = $id;
    $this->_model = $model;
    $this->_view = $view;

    $this->$model = new $model;
    $this->_view = new view;
}

function filter($data) {

    $data = trim(htmlentities(strip_tags($data)));

    if (get_magic_quotes_gpc())

    $data = stripslashes($data);
    $data = mysql_real_escape_string($data);

return $data;

}

function set($name,$value) {
    $this->_view->set($name,$value);
}

function __destruct(){
    $this->_view->render();
}

}

In my construct function it’s suppose to set the…

$this->$model = new $model; and $this->_view = new view;

But when I run either $this->_view->render(); or $gamerequests_array = $this->main_model->tab_query($tab);

It says the object doesn’t exist. Here’s the exact error message I get.

Notice: Undefined property: main_controller::$main_model and

Fatal error: Call to a member function tab_query() on a non-object

So at this point I know that the problem is the framework setting up the new objects. I’ve been trying to figure this out and at this point I need some help.

If anyone needs extra code feel free to request it, I’ll post it.

  • 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-06-02T17:23:18+00:00Added an answer on June 2, 2026 at 5:23 pm

    From this line:

    $this->$model = new $model;
    

    It appears your passing in a string and using it both as the property name and the class name. Perhaps you’re passing in a name that is not exactly main_model. Though variable/property names are case-sensitive, class names are not. So, they’re may be a case mismatch. Pass $this through get_object_vars to see what properties are available. Keep in mind that dynamically adding properties in this way will make them public.

    These lines should be examined as well:

    $this->_view = $view;
    
    $this->_view = new view;
    

    You’re overwriting the property. I’m sure this is unintentional and may be part of the problem you’re experiencing. Perhaps you’re trying to use the same approach as you did with the controller (store name, use for instantiation and access).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Before I start let me just say that I'm really new to programming so
Before you start pointing me to duplicates just know that I have read nearly
Just a quick pre-emptive question before we start to seriously investigate using Lucene. Currently
Before I start I'd just like to state that the code created by ASP.NET
Before I start let me say I am new to RavenDB. I am just
Am just started working for exporting excel spread sheet in PERL, Before start i
Ok, I think before I start I should just say that I'm a complete
Before I start with the real question, let me just say that I might
Am using Mediainfo library in my C# project,before start invoking this dll,i just ran
I am working on a Media up-loader which uploads images to Server. Before start

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.