Exemplo n.º 1
0
 public function CheckDbStructure($sFile)
 {
     if (is_file($sFile)) {
         $oXml = simplexml_load_file($sFile);
         foreach ($oXml->tables->table as $table) {
             if (!$this->isTableExists($table['name'])) {
                 $this->oMapper->CreateTableFromXml($table);
             } else {
                 foreach ($table->fields->field as $field) {
                     if (!$this->isFieldExists($table['name'], $field['name'])) {
                         $this->oMapper->AddFieldFromXml($table['name'], $field);
                     }
                 }
                 foreach ($table->indexes->index as $index) {
                     if (!$this->isIndexExists($table['name'], $index['name'])) {
                         $this->oMapper->AddIndexFromXml($table['name'], $index);
                     }
                 }
             }
         }
         return true;
     } else {
         return false;
     }
 }