-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move getSystemSchemas and isSystemSchema to Query\Utilities
If you think the class name could be better, feel free to improve it. Everybody know naming classes is difficult ^^ Signed-off-by: William Desportes <williamdes@wdes.fr>
- Loading branch information
1 parent
312bf57
commit 761045b
Showing
15 changed files
with
87 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpMyAdmin\Query; | ||
|
||
use function strtolower; | ||
|
||
/** | ||
* Some helfull functions for common tasks related to SQL results | ||
*/ | ||
class Utilities | ||
{ | ||
/** | ||
* Get the list of system schemas | ||
* | ||
* @return string[] list of system schemas | ||
*/ | ||
public static function getSystemSchemas(): array | ||
{ | ||
$schemas = [ | ||
'information_schema', | ||
'performance_schema', | ||
'mysql', | ||
'sys', | ||
]; | ||
$systemSchemas = []; | ||
foreach ($schemas as $schema) { | ||
if (! self::isSystemSchema($schema, true)) { | ||
continue; | ||
} | ||
|
||
$systemSchemas[] = $schema; | ||
} | ||
|
||
return $systemSchemas; | ||
} | ||
|
||
/** | ||
* Checks whether given schema is a system schema | ||
* | ||
* @param string $schema_name Name of schema (database) to test | ||
* @param bool $testForMysqlSchema Whether 'mysql' schema should | ||
* be treated the same as IS and DD | ||
*/ | ||
public static function isSystemSchema( | ||
string $schema_name, | ||
bool $testForMysqlSchema = false | ||
): bool { | ||
$schema_name = strtolower($schema_name); | ||
|
||
$isMySqlSystemSchema = $schema_name === 'mysql' && $testForMysqlSchema; | ||
|
||
return $schema_name === 'information_schema' | ||
|| $schema_name === 'performance_schema' | ||
|| $isMySqlSystemSchema | ||
|| $schema_name === 'sys'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters