*** Johnny escribió/wrote (Thu, 14 Aug 2008 19:25:46 +0200):
Quote:
class adodb_connection
{
public function Execute($sSql)
{
//do something with $sSql here...
$this->Execute=new adodb_recordset;
$this->Execute->Fields=5;
}
}
>
class adodb_recordset
{
public $Fields;
}
>
>
When i am trying to get the Fields variable of adodb_recordset at the
following manner, i get a "Notice: Trying to get property of non-object in
.." error.
>
=>>>>
>
$connMain = new adodb_connection;
//$rstMain = new adodb_recordset;
>
$rstMain = $connMain->Execute('sql');
echo $rstMain->Fields;
Execute() doesn't return any value so $rstMain is NULL, not an object. I
guess you mean:
echo $connMain->Execute->Fields;
Also, class adodb_connection have both a property and a method (undeclared)
with the same name. Although PHP allows that, it looks pretty confusing.
Quote:
2) If i change $this->Execute->Fields=5; in function Execute to
$this->Execute->Fieldszzzzzzzzzzzzzzzzzzzz=5; i get no error...! Shouldn't
php come with an error stating that the variable Fieldszzzzzzzzzzzzzzzzzzzz
isn't found??
I do get the very same error than above. In any case, in PHP it's optional
to declare class attributes.
--
--
http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:
http://bits.demogracia.com
-- Mi web de humor en cubitos:
http://www.demogracia.com
--