Hi,
I am passing an object to a function and i get the following error when I try to call a function of that object from within the function that the object was passed to.
Here's the error message:
PHP Fatal error: Call to a member function query() on a non-object in C:\Program Files\Apache Group\Apache\htdocs\resume2\php\clsGenericObject.php on line 197
Here are some code snippets:
This is the function that i am passing the object to:
public function __construct(GenericObject $newGenObj, $newObjectTemplateImplementer){
$this->genObj = $newGenObj;
$this->objectTemplateImplementer = $newObjectTemplateImplementer;
$this->arrFieldsInOrderWithValues = $this->genObj->getTableFieldNames();
}
My call to $this->genObj->getTableF.... is what is giving me the error:
$this->arrFieldsInOrderWithValues = $this->genObj->getTableFieldNames();
Here is the code for the genObj->getTableFieldNames() function including the line that the error message directly refers to which is line 197 inside of the GenericObject class:
public function getTableFieldNames(){
$query = "SHOW COLUMNS FROM $this->table";
$file = fopen("log.log", "a");
$message = "getTableFieldNames() : 1 : $query \n\n";
fwrite($file, $message);
fclose($file);
197 $this->sql->query($query); (NOTE sql is a private member variable of the class. sql is another object that directly communicates with a database and i know that it works fine)
$fields = $this->sql->getColumnValues("Field");
return $fields;
}//end getTableFieldNames
Thank you for any help that you can give.