Example #1
0
 public function checkDDL()
 {
     $settings = Config::getSettings(SPHORM_ENV);
     if ($settings['saveStrategy'] != 'no-checking') {
         //load meta data
         if (!isset(self::$metaData[$this->clazz])) {
             self::$metaData[$this->clazz] = array();
             $meta = $this->db->getMetaData();
             foreach ($meta as $c) {
                 self::$metaData[$this->clazz][$c['Field']] = $c;
             }
         }
         // will deal later with this...
         if ($settings['saveStrategy'] == 'ignore-undefined') {
             return true;
         }
         // column names are keys
         foreach ($this->getRealColumns() as $c => $val) {
             if ($settings['saveStrategy'] == 'halt-on-undefined' && !isset(self::$metaData[$this->clazz][$c])) {
                 throw new Exception('Column "' . $c . '" is undefined. Stopping.');
             } else {
                 if ($settings['saveStrategy'] == 'alter-on-undefined') {
                     //alter table
                     throw new Exception('Alter table on demand is not implemented yet.');
                 }
             }
         }
     }
     return false;
 }