SimpleExcel.php
[Pman.Core] / DatabaseColumns.php
index 1115d70..fd674a3 100644 (file)
@@ -22,7 +22,7 @@ class Pman_Core_DatabaseColumns extends Pman {
         return true;
     }
     
-    function get($table) {
+    function get($table, $opts = Array()) {
         $d = DB_DAtaObject::Factory($table);
         if (method_exists($d, 'availableColumns')) {
             $cols = $d->availableColumns();
@@ -34,6 +34,7 @@ class Pman_Core_DatabaseColumns extends Pman {
             
             
             $types = array();
+            $tables = array();
             $schemas = array($table => $d->table());
             
             foreach($cols as $name=>$table_col) {
@@ -42,8 +43,7 @@ class Pman_Core_DatabaseColumns extends Pman {
                     $schemas[$tbl] = DB_DataObject::Factory($tbl)->table();
                 }
                 $types[$name] = $schemas[$tbl][$col];
-                
-                
+                $tables[$name] = $tbl;
             }
              
             foreach($re['join_names'] as $c=>$f) {
@@ -58,11 +58,29 @@ class Pman_Core_DatabaseColumns extends Pman {
             $ret[]  = array(
                 'name' => $c,
                 'val' => $f,
-                'type' => isset($types[$c]) ? $types[$c] : -1,
+                'type' => isset($types[$c]) ? $this->typeToName($types[$c]) : -1,
+                'table' => isset($tables[$c]) ? $tables[$c] : "",
             );
             
         }
         
         $this->jdata($ret);
     }
-}
\ No newline at end of file
+    
+    function typeToName($t)
+    {
+        switch(true) {
+            case ($t & 64): return 'text';
+            case ($t & 32): return 'text';
+            case ($t & 4 && $t & 8): return 'datetime';
+            case ($t & 4): return 'date';
+            case ($t & 8): return 'time';
+            case ($t & 16): return 'bool';
+            case ($t & 2): return 'varchar';
+            case ($t & 1): return 'number';
+                
+        }
+        return '??';
+        
+    }
+}