Fatal error: Using $this when not in object context in ...

4 views
Skip to first unread message

newToThis

unread,
May 9, 2008, 4:24:49 AM5/9/08
to Php Object Generator
$lstSources = Source::GetDocumentList();

for ($i = 0; $i < sizeof($lstSources); $i++)
{
$source = $lstSources[$i];
...
}

--------
Hi all,
I have a beginner question -- given that a Source has many
Document(s), and that I've set up POG & databases correctly... why am
I getting the error:

Fatal error: Using $this when not in object context in /{path}/dao/
objects/class.source.php on line 310

where line 310 in class.source.php is:
function GetDocumentList($fcv_array = array(), $sortBy='',
$ascending=true, $limit='') {
$document = new Document();
$fcv_array[] = array("sourceId", "=", $this->sourceId); // line 310
$dbObjects = $document->GetList($fcv_array, $sortBy, $ascending,
$limit);
return $dbObjects;
}


====

Thanks in advance for your help!

Crispy

unread,
May 10, 2008, 10:55:31 AM5/10/08
to Php Object Generator
Hi,

simply, the GetDocumentList is not a static function.
you would need something like this:

$source = new Source();
$listSources = $source->GetDocumentList();

for consistency, all the functions in a POG object need an instatiated
object.

-Mark
Reply all
Reply to author
Forward
0 new messages