inc/DBSchema/mysql.php
authorAlan Knowles <alan@akbkhome.com>
Thu, 27 Jan 2011 15:38:21 +0000 (23:38 +0800)
committerAlan Knowles <alan@akbkhome.com>
Thu, 27 Jan 2011 15:38:21 +0000 (23:38 +0800)
inc/DBSchema/mysql.php

index fbcd69e..7d81336 100644 (file)
@@ -31,6 +31,25 @@ class MTrackDBSchema_mysql extends MTrackDBSchema_Generic
         // assume we need to create database..
         return null;
     }
+    
+    
+    function computeFieldCreate($f)
+    {
+        $str = "\t$f->name ";
+        $str .= isset($this->typemap[$f->type]) ? $this->typemap[$f->type] : $f->type;
+        if (isset($f->nullable) && $f->nullable == '0') {
+          $str .= ' NOT NULL ';
+        }
+        if (!isset($f->default)) {
+            return $str;
+        }
+        if (!strlen($f->default)) {
+            return $str . " DEFAULT ''";
+        }
+        
+        return $str . ($f->default == 'CURRENT_TIMESTAMP' ? '' : $f->default);
+    }
+    
     // may as well rewrite this.. as we have too loop throug hit anyway..
     function createTable(MTrackDBSchema_Table $table)
     {