Commit 6a9509ed by Mark

improved checkIntegrity method

parent 5220596e
...@@ -106,14 +106,13 @@ class QueryBuilder extends \yii\db\QueryBuilder ...@@ -106,14 +106,13 @@ class QueryBuilder extends \yii\db\QueryBuilder
public function checkIntegrity($check = true, $schema = '', $table = '') public function checkIntegrity($check = true, $schema = '', $table = '')
{ {
$enable = $check ? 'ENABLE' : 'DISABLE'; $enable = $check ? 'ENABLE' : 'DISABLE';
$schema = $schema ? $schema : $this->db->schema->defaultSchema;
$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='"'.$tableName.'"'; $tableName='"'.$schema.'"."'.$tableName.'"';
if(strpos($tableName,'.')!==false)
$tableName=str_replace('.','"."',$tableName);
$command .= "ALTER TABLE $tableName $enable TRIGGER ALL; "; $command .= "ALTER TABLE $tableName $enable TRIGGER ALL; ";
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment