1、增加字段类型
2、修复增加字段时的一处bug
This commit is contained in:
@@ -19,14 +19,14 @@ use think\facade\Db;
|
||||
class Datatable {
|
||||
|
||||
protected $table; /*数据库操作的表*/
|
||||
protected $fields = array(); /*数据库操作字段*/
|
||||
protected $fields = []; /*数据库操作字段*/
|
||||
protected $charset = 'utf8'; /*数据库操作字符集*/
|
||||
public $prefix = ''; /*数据库操作表前缀*/
|
||||
protected $model_table_prefix = ''; /*模型默认创建的表前缀*/
|
||||
protected $engine_type = 'MyISAM'; /*数据库引擎*/
|
||||
protected $key = 'id'; /*数据库主键*/
|
||||
public $sql = ''; /*最后生成的sql语句*/
|
||||
protected $typeAlist = array(
|
||||
protected $typeAlist = [
|
||||
"text" => "VARCHAR",
|
||||
"string" => "VARCHAR",
|
||||
"password" => "VARCHAR",
|
||||
@@ -43,7 +43,8 @@ class Datatable {
|
||||
"image" => "INT",
|
||||
"images" => "VARCHAR",
|
||||
"attach" => "VARCHAR",
|
||||
);
|
||||
"fieldlist" => "text"
|
||||
];
|
||||
|
||||
/**
|
||||
* 初始化数据库信息
|
||||
@@ -107,7 +108,7 @@ class Datatable {
|
||||
public function columField($table, $attr = array()) {
|
||||
$field_attr['table'] = $table ? $this->getTablename($table, true) : $this->table;
|
||||
$field_attr['name'] = $attr['name'];
|
||||
$field_attr['type'] = $attr['type'] ? $this->typeAlist[$attr['type']] : 'varchar';
|
||||
$field_attr['type'] = ($attr['type'] && isset($this->typeAlist[$attr['type']])) ? $this->typeAlist[$attr['type']] : 'varchar';
|
||||
if (intval($attr['length']) && $attr['length']) {
|
||||
$field_attr['length'] = "(" . $attr['length'] . ")";
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user