From cc22ce2fcf7ea6c8d754efc71a685266e18eb3b7 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Thu, 24 Dec 2015 00:09:43 +0100 Subject: [PATCH] dbs --- lib/php/db.php | 17 +++++++++++++++-- lib/php/db/table.php | 9 ++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/php/db.php b/lib/php/db.php index 5d61913d..508a68dc 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -40,6 +40,7 @@ class db extends nb { public $tables = array(); # Web + public $dbs; // others databases keys public $table; public $help_criterias = array( ' * or % for wildcar', @@ -68,7 +69,8 @@ class db extends nb { } #if (empty($this->name)) $this->name = preg_replace('/^(?:(?:sqlite:.*(.*?)(\.\w+)?)|(?:.*?dbname=([^;]+).*?))$/','\1',$this->pdo); - if (empty($this->name) and preg_match('/(?:sqlite:|dbname=)([^;\.]+)/',$this->pdo,$m)) { +# NB 22.12.15 if (empty($this->name) and preg_match('/(?:sqlite:|dbname=)([^;\.]+)/',$this->pdo,$m)) { + if (empty($this->name) and preg_match('/(?:sqlite:(?:.*\/)?|dbname=)([^;\.]+)/',$this->pdo,$m)) { $this->name = $m[1]; } if (empty($this->title)) $this->title = prettyText($this->name); @@ -319,11 +321,22 @@ EOF; '10','20','50','100','500','1000' ),array( 'html' => 'class="limit" name="limit" id="limit"', - 'selected' => $this->p('table'), + 'selected' => $this->p('limit'), 'prettyText' => true, )); $r .= ''; + // Dbs + if (!empty($this->dbs) and count($this->dbs)>1) { + $r .= ''; + $r .= ''.html_select_array($this->dbs,array( + 'html' => 'class="dbs" onchange="document.location=\''.preg_replace('/\?.*$/','',$_SERVER['REQUEST_URI']).'?db=\'+this.value"', + 'selected' => $this->name, + 'prettyText' => true, + )); + $r .= ''; + } + // Buttons $r .= DB_HTML_FORM_BUTTONS; diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 5dad705d..1f85e01b 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -298,7 +298,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. .''.PHP_EOL .'' .'' - .'' + .'' .'' .'' .''.PHP_EOL; @@ -445,10 +445,9 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. 'html' => 'name="format"', 'selected' => $this->p('format'), )); - $criteria[] = ''; + $criteria[] = ''; echo join(''.PHP_EOL,$criteria); - echo ''.PHP_EOL; } @@ -994,7 +993,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. if ($this->p('referer')) { header('Location: '.urldecode($this->p('referer'))); } else { - header('Location: ?table=' . $this->name . ($this->p('db') ? '&db='.$this->db->name : '')); + header('Location: ?table=' . $this->name . ($this->p('db') ? '&db='.$this->p('db') : '')); } #header('Location: '.str_replace('&','&',$this->url_list())); return true; @@ -1005,7 +1004,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. if ($this->p('referer')) { header('Location: '.urldecode($this->p('referer'))); } else { - header('Location: ?table=' . $this->name . ($this->p('db') ? '&db='.$this->db->name : '')); + header('Location: ?table=' . $this->name . ($this->p('db') ? '&db='.$this->p('db') : '')); } #header('Location: '.str_replace('&','&',$this->url_list())); return true; -- 2.47.3