Re: Persistent Server Variable - dirty solution using mysql & overload extension
| From: | Andrei Zmievski | Date: | Tue, 16 Apr 2002 14:13:03 +0000 |
| Subject: | Re: Persistent Server Variable - dirty solution using mysql & overload extension | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-82835@lists.php.net to get a copy of this message | ||
Alexander Belyaev wrote:
>
> Any comments, suggestions?
> ...
> function __get($prop_name, &$prop_value)
> {
> if($prop_name=='id' or $prop_name=='version' or
> $prop_name=='classname' or
> $prop_name=='data')
> {
> $prop_value = $this->$prop_name;
> return true;
> }
>
> $rt = mysql_query("select version from $this->classname where
> id=$this->id");
> $ver = mysql_result($rt,0);
> if($ver != $this->version) $this->reload();
> $prop_value = $this->data[$prop_name];
> return true;
> }
Yes. If you have existing class variables then ext/overload will automatically
use them instead of invoking __get() method. So this could be rewritten as:
function __get($prop_name, &$prop_value)
{
$rt = mysql_query("select version from $this->classname where id=$this->id");
$ver = mysql_result($rt, 0);
if ($ver != $this->version) $this->reload();
$prop_value = $this->data[$prop_name];
return true;
}
-Andrei
* "I'll need daily status reports on why you're so behind." -- Dilbert's
boss *