diff --git a/common/framework/parsers/dbqueryparser.php b/common/framework/parsers/dbqueryparser.php index 7958e2376..eb37dc680 100644 --- a/common/framework/parsers/dbqueryparser.php +++ b/common/framework/parsers/dbqueryparser.php @@ -15,10 +15,10 @@ class DBQueryParser * @param string $filename * @return object|false */ - public static function loadXML($filename) + public static function loadXML(string $filename) { // Load the XML file. - $xml = simplexml_load_file($filename); + $xml = simplexml_load_string(file_get_contents($filename)); if ($xml === false) { return false; diff --git a/common/framework/parsers/dbtable/column.php b/common/framework/parsers/dbtable/column.php index 684b37a03..119c9b0a2 100644 --- a/common/framework/parsers/dbtable/column.php +++ b/common/framework/parsers/dbtable/column.php @@ -9,6 +9,7 @@ class Column { public $name; public $type; + public $xetype; public $size; public $utf8mb4 = true; public $default_value; diff --git a/common/framework/parsers/dbtableparser.php b/common/framework/parsers/dbtableparser.php index 3ca556c01..d3d822861 100644 --- a/common/framework/parsers/dbtableparser.php +++ b/common/framework/parsers/dbtableparser.php @@ -9,20 +9,30 @@ use Rhymix\Framework\Storage; */ class DBTableParser { + /** + * Mapping for XE-compatible types. + */ + protected static $_xe_types = array( + 'bignumber' => 'bigint', + 'number' => 'bigint', + 'bigtext' => 'longtext', + 'date' => 'char(14)', + ); + /** * Load a table definition XML file. * * @param string $filename * @return object|false */ - public static function loadXML($filename) + public static function loadXML(string $filename) { // Initialize table definition. $table = new DBTable\Table; $table->name = preg_replace('/\.xml$/', '', basename($filename)); // Load the XML file. - $xml = simplexml_load_file($filename); + $xml = simplexml_load_string(file_get_contents($filename)); if ($xml === false) { return false; @@ -36,6 +46,17 @@ class DBTableParser $column->name = strval($column_info['name']); $column->type = strval($column_info['type']); + // Map XE-compatible types to database native types. + if (isset(self::$_xe_types[$column->type])) + { + $column->xetype = $column->type; + $column->type = self::$_xe_types[$column->type]; + } + else + { + $column->xetype = $column->type; + } + // Get the size. if (preg_match('/^([a-z0-9_]+)\(([0-9,\s]+)\)$/i', $column->type, $matches)) {