• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using isset() to check if model exists

#1
[eluser]Unknown[/eluser]
Hi everyone,

I have a problem with my model that has been bugging me for quite a while now. Here's how my __construct method looks like:

Code:
private $is_team;

public function __construct(){
parent::__construct();
$this->is_team = isset($this->team);

// does some other stuff bellow
}

In this model I wanted to check if another model called "team" exists. But for some reason it returns me this error:
Quote:A PHP Error was encountered

Severity: Notice
Message: Undefined property: Dashboard::$team
Filename: core/Model.php
Line Number: 51

The error disappears if I remove the line completely, so I guess it can't be caused from somewhere else.

Any ideas on how to fix or replace this?

Thanks in advance.

#2
[eluser]InsiteFX[/eluser]
If you look at the error you will see that it is telling you that $team is undefined in your Dashboard.

You need to define the $team variable.

If it is in another model or library then you need to make global like in session data.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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