Browse Source

improved checkIntegrity method

tags/2.0.0-beta
Mark 11 years ago
parent
commit
6a9509ed8d
  1. 5
      framework/yii/db/pgsql/QueryBuilder.php

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

@ -106,14 +106,13 @@ class QueryBuilder extends \yii\db\QueryBuilder
public function checkIntegrity($check = true, $schema = '', $table = '')
{
$enable = $check ? 'ENABLE' : 'DISABLE';
$schema = $schema ? $schema : $this->db->schema->defaultSchema;
$tableNames = $table ? [$table] : $this->db->schema->findTableNames($schema);
$command = '';
foreach($tableNames as $tableName)
{
$tableName='"'.$tableName.'"';
if(strpos($tableName,'.')!==false)
$tableName=str_replace('.','"."',$tableName);
$tableName='"'.$schema.'"."'.$tableName.'"';
$command .= "ALTER TABLE $tableName $enable TRIGGER ALL; ";
}

Loading…
Cancel
Save