CodeIgniter Forums
Using isset() to check if model exists - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Using isset() to check if model exists (/showthread.php?tid=52713)



Using isset() to check if model exists - El Forum - 06-23-2012

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


Using isset() to check if model exists - El Forum - 06-23-2012

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