]> git.nbdom.net Git - nb.git/commitdiff
db
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 7 Jul 2015 15:50:31 +0000 (16:50 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 7 Jul 2015 15:50:31 +0000 (16:50 +0100)
lib/php/db.php

index 11df63424a2180899ee9cf3787e0088ccd9d35dc..ed2cb559fe3b9b22f7d3089f0a47dacf23d1addd 100644 (file)
@@ -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 ''
       .'<?xml version=“1.0” encoding=“utf-8”?>'.PHP_EOL
-      .'<db src="db.php" table="'.$this->name.'">'.PHP_EOL
+      .'<db name="'.$this->db->name.'" table="'.$this->name.'" type="'.$this->db->type.'">'.PHP_EOL
     ;
   }