Skip to content

Commit

Permalink
Merge pull request #1 from salvosav/support-serialize
Browse files Browse the repository at this point in the history
Removed PsSql\Connection from serialization
  • Loading branch information
salvosav authored Jun 19, 2024
2 parents 5675656 + 9d450b4 commit 496cdcb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
{
"name": "Daniel Szakal",
"email": "[email protected]"
},
{
"name": "Salvatore Campanella",
"email": "[email protected]"
}
],
"require": {
Expand Down
9 changes: 9 additions & 0 deletions src/AutoDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/AutoRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 496cdcb

Please sign in to comment.