mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Update parser classes
This commit is contained in:
parent
59f14d8a3f
commit
43c5da7818
3 changed files with 26 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ class Column
|
|||
{
|
||||
public $name;
|
||||
public $type;
|
||||
public $xetype;
|
||||
public $size;
|
||||
public $utf8mb4 = true;
|
||||
public $default_value;
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue