Skip to content

Commit

Permalink
Fixed issue #9592: Unable to run survey when using database sessions …
Browse files Browse the repository at this point in the history
…with Postgres

Dev Bug in Yii framework - PR submitted to the Yii project
  • Loading branch information
c-schmitz committed May 19, 2015
1 parent 84380d9 commit 129a5db
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
3 changes: 0 additions & 3 deletions application/commands/InstallCommand.php
Expand Up @@ -41,9 +41,6 @@ public function run($sArgument)
$sql_file = 'mysql';
break;
case 'pgsql':
if (version_compare($this->connection->getServerVersion(),'9','>=')) {
$this->connection->createCommand("ALTER DATABASE ". $this->connection->quoteTableName($this->getDBConnectionStringProperty('dbname')) ." SET bytea_output='escape';")->execute();
}
$sql_file = 'pgsql';
break;
case 'dblib':
Expand Down
5 changes: 0 additions & 5 deletions application/controllers/InstallerController.php
Expand Up @@ -948,11 +948,6 @@ function _setup_tables($sFileName, $aDbConfig = array(), $sDatabasePrefix = '')
case 'mysqli':
$this->connection->createCommand("ALTER DATABASE ". $this->connection->quoteTableName($sDatabaseName) ." DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;")->execute();
break;
case 'pgsql':
if (version_compare($this->connection->getServerVersion(),'9','>=')) {
$this->connection->createCommand("ALTER DATABASE ". $this->connection->quoteTableName($sDatabaseName) ." SET bytea_output='escape';")->execute();
}
break;
}
} catch(Exception $e) {
return array($e->getMessage());
Expand Down
3 changes: 3 additions & 0 deletions framework/web/CDbHttpSession.php
Expand Up @@ -246,6 +246,9 @@ public function writeSession($id,$data)
{
$expire=time()+$this->getTimeout();
$db=$this->getDbConnection();

if($db->getDriverName()=='pgsql' )
$data=new CDbExpression("convert_to(".$db->quoteValue($data).", 'UTF8')");
if($db->getDriverName()=='sqlsrv' || $db->getDriverName()=='mssql' || $db->getDriverName()=='dblib')
$data=new CDbExpression('CONVERT(VARBINARY(MAX), '.$db->quoteValue($data).')');
if($db->createCommand()->select('id')->from($this->sessionTableName)->where('id=:id',array(':id'=>$id))->queryScalar()===false)
Expand Down

0 comments on commit 129a5db

Please sign in to comment.