From: Nicolas Boisselier Date: Fri, 27 May 2016 08:07:35 +0000 (+0200) Subject: host and sqlite X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=c077ddd81d825fe9130ed6262119a0db3a5f65f2;p=nb.git host and sqlite --- diff --git a/etc/dbs.yaml b/etc/dbs.yaml index e9c281f8..3d125086 100644 --- a/etc/dbs.yaml +++ b/etc/dbs.yaml @@ -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 diff --git a/lib/php/db.php b/lib/php/db.php index b29295c9..b83c9805 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -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 {