Object becomes a non-object???
Posted: Thu Sep 18, 2008 8:57 am
Here is my code:
The function is inside the class Color.
The purpose of the code is to retrieve certain values from a MySQL database based on an Id (colorId in this case). This problem has also cropped up in some of my other classes, but this is the least lengthy one and the easiest to show. Basically, what the problem is is that I get the following error when I try to execute the above code:
However, the echo is_a... line outputs a 1 which means that it should be an instance of the Color class. This doesn't make sense...how can an object suddenly become a non-object???
Code: Select all
public static function restore($color)
{
$db = DbConnection::getDbConnection(); //line 71
$sql = $db->Prepare('select groupId, hexValue, colorName from Color where colorId = ? limit 1'); //line 72
try //line 73
{ //line 74
echo is_a($color, "Color"); //line 75
$rs = $db->execute($sql, array($color->getColorId())); //line 76
} //line 77
catch (exception $e) //line 78
{ //line 79
print_r($e); //line 80
} //line 81
...The purpose of the code is to retrieve certain values from a MySQL database based on an Id (colorId in this case). This problem has also cropped up in some of my other classes, but this is the least lengthy one and the easiest to show. Basically, what the problem is is that I get the following error when I try to execute the above code:
Code: Select all
[Thu Sep 18 07:48:40 2008] [error] [client 10.25.100.99] PHP Fatal error: Call to a member function getColorId() on a non-object in /srv/www/htdocs/scheduler/dataAccess/Color.class.php on line 76