From: Nicolas Boisselier Date: Mon, 8 Jun 2015 16:08:24 +0000 (+0100) Subject: db.php for mysql X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=e031abe4347a66097609d9675369f9d04b680972;p=nb.git db.php for mysql --- diff --git a/lib/php/db.php b/lib/php/db.php index dea425d5..37db523a 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -97,8 +97,13 @@ class db { if ($this->type == 'sqlite') { $sql = "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name"; + } elseif ($this->type == 'pgsql') { $sql = "SELECT table_name FROM information_schema.tables WHERE table_type in('BASE TABLE','LOCAL TEMPORARY') AND table_schema NOT IN ('pg_catalog', 'information_schema')"; + + } elseif ($this->type == 'mysql') { + $sql = "SHOW TABLES"; + } else { err('db.tables(): Unknow db type: '.$this->type); return array(); @@ -233,6 +238,9 @@ class table { } elseif ($this->db->type == 'pgsql') { $sql = "SELECT a.attname as name, pg_catalog.format_type(a.atttypid, a.atttypmod) as type, case a.attnotnull when 't' then 1 else 0 end as notnull FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relname='$this->name' AND pg_catalog.pg_table_is_visible(c.oid) ) AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum"; + } elseif ($this->db->type == 'mysql') { + $sql = "SHOW COLUMNS FROM `$this->name`"; + } else { err('table.fields(): Unknow db type: '.$this->db->type); return array();