/** * 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); }
public function parse($definition, \Concrete\Core\Database\Connection\Connection $db) { $schema = new \Doctrine\DBAL\Schema\Schema(); foreach ($definition as $tableName => $details) { if ($db->tableExists($tableName)) { continue; } $table = $schema->createTable($tableName); if (isset($details['columns'])) { $table = $this->addColumns($table, $details['columns']); } else { throw new \Exception(t('Invalid column definition: %s in table %s', var_export($details, true), $tableName)); } $table->setPrimaryKey($details['primary']); } return $schema; }
/** * Transforms the XML from Adodb XML into * Doctrine DBAL Schema. */ public function parse(\Concrete\Core\Database\Connection\Connection $db) { $x = $this->rawXML; $schema = new \Doctrine\DBAL\Schema\Schema(); foreach ($x->table as $t) { if ($this->ignoreExistingTables && $db->tableExists($t['name'])) { continue; } $table = $schema->createTable((string) $t['name']); foreach ($t->field as $f) { $options = $this->_getColumnOptions($db, $f); $version = isset($options['version']) && $options['version'] ? true : false; unset($options['version']); $field = $table->addColumn((string) $f['name'], $this->_getColumnType($f), $options); if ($version) { $field->setPlatformOption('version', true); } } $this->_setPrimaryKeys($db, $t, $table); $this->_setIndexes($db, $t, $table); $this->_setTableOpts($db, $t, $table); } return $schema; }