]> git.nbdom.net Git - nb.git/commitdiff
host and sqlite
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 27 May 2016 08:07:35 +0000 (10:07 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 27 May 2016 08:07:35 +0000 (10:07 +0200)
etc/dbs.yaml
lib/php/db.php

index e9c281f8fefd434eeebe3ef3dbb19596aa49c0ec..3d125086508944311305e1d7f3f9e5392c6a4cae 100644 (file)
@@ -5,14 +5,14 @@ _mysql:
   type: mysql
 
 crypt:
-  pdo: 'sqlite:/dev/shm/crypt.db'
+  type: sqlite
+  host: /dev/shm/crypt.db
 
 rt:
   pdo: 'pgsql:host=db.rt.semantico.net;port=5432;dbname=rtdb;user=rtuser;password='
   title: 'RT'
 
 izi:
-  #pdo: 'mysql:host=admin.izideal.com;port=3306;dbname=izi'
   title: Mysql Izi
   host: sql.izideal.vpn
   default_table: process
index b29295c91a920b2d871c72901bf7a880ec441c44..b83c9805e87eeb16afcd47f5d999af0c5b4acf99 100644 (file)
@@ -82,12 +82,13 @@ class Db extends nb {
        function connect_init() {
     if (empty($this->pdo) and $this->type) $this->pdo = $this->type.':';
     if (empty($this->type)) $this->type = strtolower(preg_replace('/^([^:]+):.*$/','\1',$this->pdo));
-    if( !$this->type ) return false;
+    if (!$this->type) return false;
 
     if ($this->type('use_path')) {
-      $this->file = preg_replace('/^\w+:/','',$this->pdo);
-      if ($p = $this->p('db.host')) $this->file = $p;
-      $this->host = $this->file;
+      if ($p = $this->p('db.host')) $this->host = $p;
+      if (empty($this->host)) $this->host = preg_replace('/^\w+:/','',$this->pdo);
+      # Add file
+      if (trim($this->pdo,'pdo:'.$this->type)=='') $this->pdo .= $this->host;
 
     } else {
 
@@ -136,8 +137,8 @@ class Db extends nb {
     if (!$this->type(null)) $this->bye("Unknow type = `".$this->type."`");
 
     # Connect
-    if ($this->type('use_path') and !is_readable($this->file)) {
-      $this->bye("Can't read database file `".$this->file."` type=`$this->type`",false);
+    if ($this->type('use_path') and !is_readable($this->host)) {
+      $this->bye("Can't read database file `".$this->host."` type=`$this->type`",false);
     }
 
     try {