From ec1e3174e153d1866b4ba1039a64b75970a944a9 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 7 Jul 2015 16:50:31 +0100 Subject: [PATCH] db --- lib/php/db.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/php/db.php b/lib/php/db.php index 11df6342..ed2cb559 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -14,6 +14,7 @@ class db { public $tables = array(); public $conn; public $title; + public $name; public $type; public $help_criterias = array( ' * or % for wildcar', @@ -30,11 +31,14 @@ class db { #bye($db['conn']); $this->conn = new PDO($db['conn']); + #if (empty($this->name)) $this->name = preg_replace('/^(?:(?:sqlite:.*(.*?)(\.\w+)?)|(?:.*?dbname=([^;]+).*?))$/','\1',$db['conn']); + if (empty($this->name) and preg_match('/(?:sqlite:|dbname=)([^;\.]+)/',$db['conn'],$m)) { + $this->name = $m[1]; + } + if (empty($this->title)) $this->title = prettyText($this->name); if ($this->type == 'sqlite') { - if (empty($this->title)) $this->title = preg_replace('/^.*?:.*(.*?)(\.\w+)?$/','\1',$db['conn']); - $this->conn->sqliteCreateFunction('regexp', function ($pattern, $data, $delimiter = '~', $modifiers = 'isuS') { if (isset($pattern, $data) === true) { @@ -832,7 +836,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. function rows_begin_xml() { echo '' .''.PHP_EOL - .''.PHP_EOL + .''.PHP_EOL ; } -- 2.47.3