Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

(Fixes issue 1039)

  • Loading branch information...
commit 417c4d252693072b931f3e2f9442edab3ea66dbe 1 parent 8bb5c9a
qiang.xue authored
Showing with 17 additions and 9 deletions.
  1. +1 −0  CHANGELOG
  2. +16 −9 framework/db/schema/CDbSchema.php
View
1  CHANGELOG
@@ -6,6 +6,7 @@ Version 1.1.3 to be released
----------------------------
- Bug #856: Logout doesn't work when CWebUser::identityCookie is configured and allowAutoLogin is set true (Qiang)
- Bug #1027: CButtonColumn->buttons is ignored (Sam Dark)
+- Bug #1039: Table prefix feature did not work with PostgreSQL and AR (Qiang)
- Bug #1046: Fixed the bug that CDbFixtureManager did not properly initialize the fixture data (Qiang)
- Bug #0147: Fixed the bug that changing CAuthItem.description value would cause an exception when using CPhpAuthManager (Qiang)
- Bug #1050: Fixed the bug that filter conditions were prefilled with default values when using an AR model in CGridView (Qiang)
View
25 framework/db/schema/CDbSchema.php
@@ -59,19 +59,26 @@ public function getTable($name)
{
if(isset($this->_tables[$name]))
return $this->_tables[$name];
- else if(!isset($this->_cacheExclude[$name]) && ($duration=$this->_connection->schemaCachingDuration)>0 && $this->_connection->schemaCacheID!==false && ($cache=Yii::app()->getComponent($this->_connection->schemaCacheID))!==null)
+ else
{
- $key='yii:dbschema'.$this->_connection->connectionString.':'.$this->_connection->username.':'.$name;
- if(($table=$cache->get($key))===false)
+ if($this->_connection->tablePrefix!='' && strpos($name,'{{')!==false)
+ $realName=preg_replace('/\{\{(.*?)\}\}/',$this->_connection->tablePrefix.'$1',$name);
+ else
+ $realName=$name;
+ if(!isset($this->_cacheExclude[$name]) && ($duration=$this->_connection->schemaCachingDuration)>0 && $this->_connection->schemaCacheID!==false && ($cache=Yii::app()->getComponent($this->_connection->schemaCacheID))!==null)
{
- $table=$this->createTable($name);
- if($table!==null)
- $cache->set($key,$table,$duration);
+ $key='yii:dbschema'.$this->_connection->connectionString.':'.$this->_connection->username.':'.$name;
+ if(($table=$cache->get($key))===false)
+ {
+ $table=$this->createTable($realName);
+ if($table!==null)
+ $cache->set($key,$table,$duration);
+ }
+ return $this->_tables[$name]=$table;
}
- return $this->_tables[$name]=$table;
+ else
+ return $this->_tables[$name]=$this->createTable($realName);
}
- else
- return $this->_tables[$name]=$this->createTable($name);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.