💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
```php /用于查看特定表的详细设计信息 //desc 是 describe的缩写 //describe用于查看特定表的详细设计信息 //describe($tablename) //查询出表的列信息 //show_columns_from($tablename) //这个是查询建表语句 //show_create_table($tablename) //删除字段 //alter_table_drop($tablename, $field) //修改字段 //alter_table_change($tablename, $oldfield, $newfield, $field_type, $isnot, $as) /* 修改字段 * * $tablename 表名 * $field 字段名 * $field_type 字段类型 * $isnot 是否为空 * $as 字段注释 * 添加字段alter_table_add($tablename, $field, $field_type, $isnot, $as) $tablename 表名 $field 字段名 $field_type 字段类型 $isnot 是否为空 $as 字段注释 删除表 drop_table($oldtablename) 修改表名create_table($oldtablename, $newtablename) 创建表 create_table($tablename, $as) * */ //创建表 public function create_table($tablename, $as) { $sql = "create table " . $tablename; $sql .= " (id int not null auto_increment,typeid varchar(40) not null comment '类别id', "; $sql .= "creationtime int(10) not null comment '创建时间',updatetime int(10) not null comment '更新时间' ,"; $sql .= "primary key ( id ))auto_increment = 1 engine=MyISAM default charset=utf8 COMMENT='" . $as . "'"; Db::query($sql); } //修改表名 public function create_table($oldtablename, $newtablename) { $sql = "rename table " . $oldtablename . " to " . $newtablename . ""; Db::query($sql); } //删除表 public function drop_table($oldtablename) { $sql = "drop table " . $oldtablename; Db::query($sql); } /* * 添加字段 * $tablename 表名 * $field 字段名 * $field_type 字段类型 * $isnot 是否为空 * $as 字段注释 * */ public function alter_table_add($tablename, $field, $field_type, $isnot, $as) { $sql = "alter table " . $tablename . " add " . $field . " " . $field_type . " " . $isnot . " " . " comment '" . $as . "'"; Db::query($sql); } //修改字段 /* 修改字段 * * $tablename 表名 * $field 字段名 * $field_type 字段类型 * $isnot 是否为空 * $as 字段注释 * */ public function alter_table_change($tablename, $oldfield, $newfield, $field_type, $isnot, $as) { $sql = "alter table " . $tablename . " change " . $oldfield . " " . $field . " " . $field_type . " " . $isnot . " comment '" . $as . "'"; Db::query($sql); } //删除字段 public function alter_table_drop($tablename, $field) { $sql = "alter table " . $tablename . " drop column " . $field; Db::query($sql); } //用于查看特定表的详细设计信息 //desc 是 describe的缩写 //describe用于查看特定表的详细设计信息 public function describe($tablename) { $sql = "describe " . $tablename; Db::query($sql); } //查询出表的列信息 public function show_columns_from($tablename) { $sql = "show columns from " . $tablename; Db::query($sql); } //这个是查询建表语句 public function show_create_table($tablename) { $sql = "show create table " . $tablename; Db::query($sql); } ``` ```php //创建表 $sql="create table ".$tablename." (id int not null auto_increment,typeid varchar(40) not null comment '类别id', "; $sql.="catid smallint(5) not null comment '栏目id',title varchar(80) not null comment '标题',keywords varchar(40) not null comment '关键字',description mediumtext not null comment '描述',"; $sql.="url char(100) not null comment '链接地址',listorder tinyint(80) not null comment '排序',inputtime int(10) not null comment '添加时间',updatetime int(10) not null comment '更新时间' ,"; $sql.="primary key ( id ))auto_increment = 1 engine=MyISAM default charset=utf8 "; //修改表名 $sql="rename table ".$find['tablename']." to ".$_POST['tablename'].""; //删除表 $sql="drop table ".$find['tablename']; //添加字段 $sql="alter table ".$modfind['tablename']." add ".$_POST['field']." " .$_POST['field_type']." ".$_POST['isnot']." "." comment '".$_POST['name']."'"; //修改字段 $sql="alter table ".$modfind['tablename']." change ".$model_fieldid['field']." ".$_POST['field']." " .$_POST['field_type']." ".$_POST['isnot']." comment '".$_POST['name']."'"; //删除字段 $sql= "alter table ".$modfind['tablename']. " drop column ".$find['field']; //用于查看特定表的详细设计信息 $sql="describe(desc)表名 "; //desc 是 describe的缩写 //describe用于查看特定表的详细设计信息 //查询出表的列信息 $sql="show columns from 表名"; //这个是查询建表语句 $sql="show create table 表名"; ```