Skip to content

Commit

Permalink
Model implements \\Serializable
Browse files Browse the repository at this point in the history
  • Loading branch information
aleechou committed Jun 8, 2012
1 parent 9075244 commit 5559b3e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
6 changes: 2 additions & 4 deletions class/auth/Id.php
Expand Up @@ -162,14 +162,12 @@ static public function makeActiveInfo(IIdentity $aId)

public function serialize ()
{
$arrData['model'] =& $this->aModel ;
return serialize( $arrData ) ;
return serialize( $this->aModel ) ;
}

public function unserialize ($sSerialized)
{
$arrData = unserialize($sSerialized) ;
$this->aModel =& $arrData['model'] ;
$this->aModel = unserialize($sSerialized) ;
}

public function userId()
Expand Down
26 changes: 25 additions & 1 deletion class/mvc/model/Model.php
Expand Up @@ -8,7 +8,7 @@
use org\jecat\framework\db\DB;
use org\jecat\framework\lang\Exception;

class Model implements \Iterator, \ArrayAccess
class Model implements \Iterator, \ArrayAccess, \Serializable
{
public function __construct($table,$sPrototypeName,$primaryKeys=null,$columns=null)
{
Expand Down Expand Up @@ -695,6 +695,30 @@ function valid($sChildName = null)
}
}

// implements \Serializable
public function serialize()
{
return serialize(array(
$this->aPrototype ,
$this->arrData ,
$this->sDataPrefix ,
$this->nDataPrefixLength ,
)) ;
}

/**
* @param serialized
*/
public function unserialize($serialized)
{
list(
$this->aPrototype
, $this->arrData
, $this->sDataPrefix
, $this->nDataPrefixLength
) = unserialize($serialized) ;
}

const ignore = '~-+ignore this arg+-~' ;
const primaryKeys = '~-+use primary keys+-~' ;
const asWhereClause = true ;
Expand Down

0 comments on commit 5559b3e

Please sign in to comment.