Adding database prefix check in Model::setDataSource()

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6501 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-03-01 20:30:01 +00:00
parent 5ce4469867
commit 9fbf783286

View file

@ -2384,10 +2384,10 @@ class Model extends Overloadable {
$this->useDbConfig = $dataSource;
}
$db =& ConnectionManager::getDataSource($this->useDbConfig);
if (!empty($oldConfig) && isset($oldDb->config['prefix']) && isset($db->config['prefix'])) {
if (!empty($oldConfig) && isset($db->config['prefix'])) {
$oldDb =& ConnectionManager::getDataSource($oldConfig);
if (empty($this->tablePrefix) || ($this->tablePrefix == $oldDb->config['prefix'])) {
if (empty($this->tablePrefix) || (!isset($oldDb->config['prefix']) || $this->tablePrefix == $oldDb->config['prefix'])) {
$this->tablePrefix = $db->config['prefix'];
}
} elseif (isset($db->config['prefix'])) {