]> git.nbdom.net Git - nb.git/commitdiff
db.php for mysql
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 8 Jun 2015 16:08:24 +0000 (17:08 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 8 Jun 2015 16:08:24 +0000 (17:08 +0100)
lib/php/db.php

index dea425d592bf650c731427f9b6956b9be04d8e5e..37db523ae01746ef5708909c9354c4dd15e0417b 100644 (file)
@@ -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();