Browse Source

code style fix.

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
fdca106ece
  1. 18
      framework/yii/db/pgsql/QueryBuilder.php

18
framework/yii/db/pgsql/QueryBuilder.php

@ -7,6 +7,7 @@
*/ */
namespace yii\db\pgsql; namespace yii\db\pgsql;
use yii\base\InvalidParamException; use yii\base\InvalidParamException;
/** /**
@ -76,16 +77,16 @@ class QueryBuilder extends \yii\db\QueryBuilder
{ {
$table = $this->db->getTableSchema($tableName); $table = $this->db->getTableSchema($tableName);
if ($table !== null && $table->sequenceName !== null) { if ($table !== null && $table->sequenceName !== null) {
$sequence='"'.$table->sequenceName.'"'; $sequence = '"' . $table->sequenceName . '"';
if (strpos($sequence,'.')!==false) { if (strpos($sequence, '.') !== false) {
$sequence=str_replace('.','"."',$sequence); $sequence = str_replace('.', '"."', $sequence);
} }
$tableName = $this->db->quoteTableName($tableName); $tableName = $this->db->quoteTableName($tableName);
if ($value === null) { if ($value === null) {
$key = reset($table->primaryKey); $key = reset($table->primaryKey);
$value="(SELECT COALESCE(MAX(\"{$key}\"),0) FROM {$tableName})+1"; $value = "(SELECT COALESCE(MAX(\"{$key}\"),0) FROM {$tableName})+1";
} else { } else {
$value = (int)$value; $value = (int)$value;
} }
@ -111,9 +112,8 @@ class QueryBuilder extends \yii\db\QueryBuilder
$tableNames = $table ? [$table] : $this->db->schema->findTableNames($schema); $tableNames = $table ? [$table] : $this->db->schema->findTableNames($schema);
$command = ''; $command = '';
foreach($tableNames as $tableName) foreach ($tableNames as $tableName) {
{ $tableName = '"' . $schema . '"."' . $tableName . '"';
$tableName='"'.$schema.'"."'.$tableName.'"';
$command .= "ALTER TABLE $tableName $enable TRIGGER ALL; "; $command .= "ALTER TABLE $tableName $enable TRIGGER ALL; ";
} }

Loading…
Cancel
Save