Skip to content
Permalink
Browse files

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
  • Loading branch information...
markstory committed Apr 22, 2013
1 parent c2c0964 commit 62660c67069f54b92f302cd2f0eff6ef075e3b2e
Showing with 3 additions and 2 deletions.
  1. +1 −2 lib/Cake/Model/ConnectionManager.php
  2. +2 −0 lib/Cake/Model/Model.php
@@ -86,8 +86,7 @@ public static function getDataSource($name) {
}
if (!empty(self::$_dataSources[$name])) {
$return = self::$_dataSources[$name];
return $return;
return self::$_dataSources[$name];
}
if (empty(self::$_connectionsEnum[$name])) {
@@ -1689,6 +1689,8 @@ public function save($data = null, $validate = true, $fieldList = array()) {
}
}
$db = $this->getDataSource();
if (empty($this->data[$this->alias][$this->primaryKey])) {
unset($this->data[$this->alias][$this->primaryKey]);
}

0 comments on commit 62660c6

Please sign in to comment.
You can’t perform that action at this time.