/** * Transforms the XML from Adodb XML into * Doctrine DBAL Schema. */ public function parse(\Concrete\Core\Database\Connection\Connection $db) { $filter = null; if ($this->ignoreExistingTables) { $filter = function ($tableName) use($db) { return $db->tableExists($tableName) ? false : true; }; } return \DoctrineXml\Parser::fromDocument($this->rawXML->asXML(), $db->getDatabasePlatform(), true, false, $filter); }
protected function _getColumnOptions(\Concrete\Core\Database\Connection\Connection $db, \SimpleXMLElement $column) { $type = strtoupper((string) $column['type']); $size = (string) $column['size']; $options = array(); if ($size) { if (in_array($type, array('N', 'F'))) { $precision = explode('.', $size); $options['precision'] = $precision[0]; $options['scale'] = $precision[1]; } else { $options['length'] = $size; } } switch ($type) { case 'X': $options['length'] = 65535; // this means 'X' will result in a 'TEXT' column break; case 'X2': // no length limitation -> this means 'X2' will result in a 'LONGTEXT' column break; } if ($column->unsigned || $column->UNSIGNED) { $options['unsigned'] = true; } if ($column->default) { if (isset($column->default['value'])) { $options['default'] = (string) $column->default['value']; } if (isset($column->default['VALUE'])) { $options['default'] = (string) $column->default['VALUE']; } } if ($column->DEFAULT) { if (isset($column->DEFAULT['value'])) { $options['default'] = (string) $column->DEFAULT['value']; } if (isset($column->DEFAULT['VALUE'])) { $options['default'] = (string) $column->DEFAULT['VALUE']; } } if ($column->notnull || $column->NOTNULL) { $options['notnull'] = true; } else { $options['notnull'] = false; } if ($column->autoincrement || $column->AUTOINCREMENT) { $options['autoincrement'] = true; } if ($type == 'T' && isset($column->deftimestamp) || isset($column->DEFTIMESTAMP)) { $platform = $db->getDatabasePlatform(); $options['default'] = $platform->getCurrentTimestampSQL(); $options['version'] = true; } return $options; }