|
@@ -73,11 +73,13 @@ trait traitDatabase
|
|
|
{
|
|
|
if (!$database) $database = $this->currentDB;
|
|
|
$sql = "SELECT * from information_schema.COLUMNS where table_name = '" . $table . "' and table_schema = '" . $database . "'";
|
|
|
- $data = ['fields' => [],
|
|
|
- 'rules' => [
|
|
|
- 'pri' => [], 'required' => []
|
|
|
- ]
|
|
|
- ];
|
|
|
+ $data = array(
|
|
|
+ 'fields' => array(),
|
|
|
+ 'rules' => array(
|
|
|
+ 'pri' => array(),
|
|
|
+ 'required' => array()
|
|
|
+ )
|
|
|
+ );
|
|
|
|
|
|
$rs = $this->setQuery($sql);
|
|
|
while ($row = $rs->fetch()) {
|
|
@@ -92,24 +94,24 @@ trait traitDatabase
|
|
|
if ($row['IS_NULLABLE'] == 'NO') {
|
|
|
$data['rules']['required'][] = $row['COLUMN_NAME'];
|
|
|
}
|
|
|
- if (in_array($row['DATA_TYPE'], ['varchar', 'char'])) {
|
|
|
+ if (in_array($row['DATA_TYPE'], array('varchar', 'char'))) {
|
|
|
$data['rules']['maxlength'][$row['COLUMN_NAME']] = $row['CHARACTER_MAXIMUM_LENGTH'];
|
|
|
}
|
|
|
- if (in_array($row['DATA_TYPE'], ['mediumtext', 'TINYTEXT', 'text', 'longtext'])) {
|
|
|
+ if (in_array($row['DATA_TYPE'], array('mediumtext', 'TINYTEXT', 'text', 'longtext'))) {
|
|
|
$data['rules']['text'][] = $row['COLUMN_NAME'];
|
|
|
}
|
|
|
- if (in_array($row['DATA_TYPE'], ['bigint', 'int', 'smallint', 'tinyint', 'integer'])) {
|
|
|
+ if (in_array($row['DATA_TYPE'], array('bigint', 'int', 'smallint', 'tinyint', 'integer'))) {
|
|
|
preg_match('/[\d]{1,}/', $row['COLUMN_TYPE'], $matches);
|
|
|
$data['rules']['int'][$row['COLUMN_NAME']] = $matches[0];
|
|
|
$data['rules']['number'][] = $row['COLUMN_NAME'];
|
|
|
}
|
|
|
- if (in_array($row['DATA_TYPE'], ['float', 'double', 'decimal'])) {
|
|
|
+ if (in_array($row['DATA_TYPE'], array('float', 'double', 'decimal'))) {
|
|
|
$data['rules']['float'][$row['COLUMN_NAME']] = $this->getValueFromBrackets($row['COLUMN_TYPE']);
|
|
|
}
|
|
|
- if (in_array($row['DATA_TYPE'], ['timestamp', 'datatime'])) {
|
|
|
+ if (in_array($row['DATA_TYPE'], array('timestamp', 'datatime'))) {
|
|
|
$data['rules']['timestamp'][] = $row['COLUMN_NAME'];
|
|
|
}
|
|
|
- if (in_array($row['DATA_TYPE'], ['enum', 'set'])) {
|
|
|
+ if (in_array($row['DATA_TYPE'], array('enum', 'set'))) {
|
|
|
$data['rules']['sets'][$row['COLUMN_NAME']] = $this->getValueFromBrackets($row['COLUMN_TYPE']);
|
|
|
}
|
|
|
if (isset($row['COLUMN_DEFAULT'])) {
|