Fixing lazy loading of database conenction when using prefixes and performing delete operations

This commit is contained in:
José Lorenzo Rodríguez 2011-02-23 00:49:37 -04:30
parent fc060b5e9c
commit 8f62d01701
2 changed files with 2 additions and 2 deletions

View file

@ -1852,7 +1852,7 @@ class DboSource extends DataSource {
$joins = array_merge($model->getAssociated('hasOne'), $model->getAssociated('belongsTo'));
foreach ($joins as $assoc) {
if (isset($model->{$assoc}) && $model->useDbConfig == $model->{$assoc}->useDbConfig) {
if (isset($model->{$assoc}) && $model->useDbConfig == $model->{$assoc}->useDbConfig && $model->{$assoc}->getDataSource()) {
$assocData = $model->getAssociated($assoc);
$join[] = $this->buildJoinStatement(array(
'table' => $this->fullTableName($model->{$assoc}),

View file

@ -1882,7 +1882,7 @@ class Model extends Object {
if (!$filters || !$this->exists()) {
return false;
}
$db = ConnectionManager::getDataSource($this->useDbConfig);
$db = $this->getDataSource();
$this->_deleteDependent($id, $cascade);
$this->_deleteLinks($id);