diff --git a/composer.json b/composer.json index b814b02..6cdaea9 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,10 @@ { "name": "Daniel Szakal", "email": "dszakal89@icloud.com" + }, + { + "name": "Salvatore Campanella", + "email": "salvo.sav@gmail.com" } ], "require": { diff --git a/src/AutoDb.php b/src/AutoDb.php index 18c6583..1543b08 100644 --- a/src/AutoDb.php +++ b/src/AutoDb.php @@ -50,6 +50,15 @@ protected function __construct($sqlResource, $redisInstance = null, $connectionI $this->_connectionIdent = $connectionIdent; } + public function __sleep() + { + // Exclude the _sqlResource property from serialization + $properties = get_object_vars($this); + unset($properties['_sqlResource']); + + return array_keys($properties); + } + /** * * @param mysqli $sqlResource - one MySQL connection <-> One AutoDb instance diff --git a/src/AutoRecord.php b/src/AutoRecord.php index 5c1f434..f23cf1b 100644 --- a/src/AutoRecord.php +++ b/src/AutoRecord.php @@ -76,6 +76,15 @@ protected function __construct(AutoDb $autoDb, $table, $columnRules, $sqlResourc $this->_primaryKey = $columnRules['__primarykey']; } + public function __sleep() + { + // Exclude the _sqlResource property from serialization + $properties = get_object_vars($this); + unset($properties['_sqlResource']); + + return array_keys($properties); + } + private function initAttrsEmpty() { foreach ($this->_columnRules as $key => $value) { $this->_attributes[$key] = null;