mirror of
https://github.com/vrana/adminer.git
synced 2025-08-15 02:54:28 +02:00
Move on_actions to Driver
This commit is contained in:
@@ -198,6 +198,7 @@ if (isset($_GET["mssql"])) {
|
||||
var $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL");
|
||||
var $functions = array("len", "lower", "round", "upper");
|
||||
var $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
|
||||
var $onActions = "NO ACTION|CASCADE|SET NULL|SET DEFAULT";
|
||||
|
||||
function __construct($connection) {
|
||||
parent::__construct($connection);
|
||||
@@ -705,8 +706,6 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . q($table)) as $row
|
||||
}
|
||||
|
||||
function driver_config() {
|
||||
global $on_actions;
|
||||
$on_actions = str_replace('RESTRICT|', '', $on_actions);
|
||||
return array(
|
||||
'possible_drivers' => array("SQLSRV", "PDO_SQLSRV", "PDO_DBLIB"),
|
||||
'jush' => "mssql",
|
||||
|
@@ -637,12 +637,12 @@ if (!defined("DRIVER")) {
|
||||
* @return array [$name => ["db" => , "ns" => , "table" => , "source" => [], "target" => [], "on_delete" => , "on_update" => ]]
|
||||
*/
|
||||
function foreign_keys($table) {
|
||||
global $connection, $on_actions;
|
||||
global $connection, $driver;
|
||||
static $pattern = '(?:`(?:[^`]|``)+`|"(?:[^"]|"")+")';
|
||||
$return = array();
|
||||
$create_table = $connection->result("SHOW CREATE TABLE " . table($table), 1);
|
||||
if ($create_table) {
|
||||
preg_match_all("~CONSTRAINT ($pattern) FOREIGN KEY ?\\(((?:$pattern,? ?)+)\\) REFERENCES ($pattern)(?:\\.($pattern))? \\(((?:$pattern,? ?)+)\\)(?: ON DELETE ($on_actions))?(?: ON UPDATE ($on_actions))?~", $create_table, $matches, PREG_SET_ORDER);
|
||||
preg_match_all("~CONSTRAINT ($pattern) FOREIGN KEY ?\\(((?:$pattern,? ?)+)\\) REFERENCES ($pattern)(?:\\.($pattern))? \\(((?:$pattern,? ?)+)\\)(?: ON DELETE ($driver->onActions))?(?: ON UPDATE ($driver->onActions))?~", $create_table, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $match) {
|
||||
preg_match_all("~$pattern~", $match[2], $source);
|
||||
preg_match_all("~$pattern~", $match[5], $target);
|
||||
|
@@ -476,7 +476,7 @@ ORDER BY a.attnum") as $row
|
||||
}
|
||||
|
||||
function foreign_keys($table) {
|
||||
global $on_actions;
|
||||
global $driver;
|
||||
$return = array();
|
||||
foreach (
|
||||
get_rows("SELECT conname, condeferrable::int AS deferrable, pg_get_constraintdef(oid) AS definition
|
||||
@@ -492,8 +492,8 @@ ORDER BY conkey, conname") as $row
|
||||
$row['table'] = idf_unescape($match2[4]);
|
||||
}
|
||||
$row['target'] = array_map('Adminer\idf_unescape', array_map('trim', explode(',', $match[3])));
|
||||
$row['on_delete'] = (preg_match("~ON DELETE ($on_actions)~", $match[4], $match2) ? $match2[1] : 'NO ACTION');
|
||||
$row['on_update'] = (preg_match("~ON UPDATE ($on_actions)~", $match[4], $match2) ? $match2[1] : 'NO ACTION');
|
||||
$row['on_delete'] = (preg_match("~ON DELETE ($driver->onActions)~", $match[4], $match2) ? $match2[1] : 'NO ACTION');
|
||||
$row['on_update'] = (preg_match("~ON UPDATE ($driver->onActions)~", $match[4], $match2) ? $match2[1] : 'NO ACTION');
|
||||
$return[$row['conname']] = $row;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user