public checkIntegrity ( boolean $check = true, string $schema = '', string $table = '' ) : string | ||
$check | boolean | whether to turn on or off the integrity check. |
$schema | string | the schema of the tables. Defaults to empty string, meaning the current or default schema. |
$table | string | the table name. Defaults to empty string, meaning that no table will be changed. |
return | string | the SQL statement for checking integrity |
public function checkIntegrity($check = true, $schema = '', $table = '')
{
if ($schema !== '') {
$table = "{$schema}.{$table}";
}
$table = $this->db->quoteTableName($table);
if ($this->db->getTableSchema($table) === null) {
throw new InvalidParamException("Table not found: {$table}");
}
$enable = $check ? 'CHECK' : 'NOCHECK';
return "ALTER TABLE {$table} {$enable} CONSTRAINT ALL";
}