mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Re-assign $db after beforeSave.
This allows model/behavior methods to change the datasource in the beforeSave callback. If you use drivers from different SQL platforms things will go very poorly. Fixes #3606
This commit is contained in:
parent
c2c096428c
commit
62660c6706
2 changed files with 3 additions and 2 deletions
|
@ -86,8 +86,7 @@ class ConnectionManager {
|
|||
}
|
||||
|
||||
if (!empty(self::$_dataSources[$name])) {
|
||||
$return = self::$_dataSources[$name];
|
||||
return $return;
|
||||
return self::$_dataSources[$name];
|
||||
}
|
||||
|
||||
if (empty(self::$_connectionsEnum[$name])) {
|
||||
|
|
|
@ -1689,6 +1689,8 @@ class Model extends Object implements CakeEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
$db = $this->getDataSource();
|
||||
|
||||
if (empty($this->data[$this->alias][$this->primaryKey])) {
|
||||
unset($this->data[$this->alias][$this->primaryKey]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue