```
/用于查看特定表的詳細設計信息
//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);
}
```
- 課程介紹
- thinkphp5.0
- 安裝
- 開發規范
- 目錄結構
- 配置參數
- 系統常量
- tp5自帶的函數
- 助手函數
- 擴展類庫
- 基本類庫
- Workerman
- think-queue
- 驗證碼
- 圖片
- 權限認證
- 課前準備
- 數據庫設計
- 模塊設計
- 管理員管理
- 添加
- 編輯
- 刪除和批量刪除
- 列表頁
- 實列
- 權限管理
- 操作日志
- 基于行為的日記錄
- 行為日志的擴展
- 助手類庫
- 自建函數
- 將數組轉成uri字符串
- 獲取當前服務器的IP
- curl-post
- 截取文字中間的字符串
- 檢查中文姓名
- 省市區分別截取
- 抽獎概率問題
- 短信郵箱模板替換
- 生成csv
- PHP 圖片轉base64
- 銀行卡驗證
- json返回接口封裝
- 無限極分類
- 病毒
- xml和數組互轉
- xml轉成數組
- 數組轉xml
- tp控制器相關
- 獲取thinkph5下控制器和方法名
- 后臺查詢的簡單封裝
- 網址信息
- 獲取網站logo
- 判斷url是否存在
- 獲取title
- 判斷遠程文件是否存在
- 獲取頁面所有鏈接
- 過濾
- 截取
- 時間
- 獲取服務器信息
- 根據id生成唯一邀請碼
- 隨機顏色
- 數組字符串互換
- 創建多級目錄
- 懶人查詢
- 時間和時間戳轉換
- 房間id生菜
- 獲取需要的數組元素
- 文件和文件夾
- 文件類庫
- 文件夾
- 七牛云
- 七牛云運用場景
- 七牛云使用實例
- 郵箱
- 郵箱驗證
- 郵箱發送
- 數據庫
- 數據庫在thinkphp中的補充方法
- 備份和安全
- sql執行
- 數據庫備份2
- 時間日歷
- 時間格式化
- 日歷
- 圖片相關
- 自動獲取圖片主題顏色
- 獲取html中的圖片路徑
- 獲取圖片場景
- 獲取圖片實踐
- 圖片處理類
- 圖片處理場景
- 圖片處理實踐
- 數據驗證分析
- 身份證相關
- 新聞
- 自建類庫
- 簡易分類庫
- php 壓縮CSS代碼
- 身份證
- 分詞和抽詞
- 分詞應用場景
- 分詞實踐
- 中文轉拼音
- 中文轉拼音場景
- 中文轉拼音實踐
- 二維碼操作
- 二維碼場景
- 二維碼實踐
- 短地址
- PHPWord
- 插件化
- 插件擴展庫
- 插件列表
- 插件安裝和卸載
- 插件實踐
- 插件的離線安裝
- 計劃任務
- 計劃任務安裝
- 計劃任務實踐
- 定時器
- 注冊登錄
- 普通登錄注冊
- 第三方登錄注冊
- jwt接口登錄注冊
- 短信
- 飛鴿短信
- 阿里短信
- 消息隊列
- 網站地圖
- 全站靜態化
- 緩存
- 文件導出
- PDF生成
- phpword
- PHPExcel
- 其他類庫
- 百度
- 百度語音
- 快遞
- 跨域問題
- 寶塔
- 搜索記錄