note 28177 deleted from ref.objaggregation by sobak
| From: | sobak@php.net | Date: | Sat, 01 Jun 2019 06:20:01 +0000 |
| Subject: | note 28177 deleted from ref.objaggregation by sobak | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211157@lists.php.net to get a copy of this message | ||
Note Submitter: Greg Beaver firstname at chiaraquartet dot net
----
If you need to serialize an object for sessions or other purposes, and want to save aggregation
state, extend it from a base class such as this one, and use $this->agg/$this->unagg instead
of aggregate/deaggregate
<?php
class base
{
var $_aggregates = array();
function agg($agg)
{
aggregate($this,$agg);
$this->_aggregates[$agg] = 1;
}
function unagg($agg = false)
{
if ($agg)
{
deaggregate($this,$agg);
unset($this->_aggregates[$agg]);
} else
{
deaggregate($this);
$this->_aggregates = array();
}
}
}
?>