時間:2020-09-25
瀏覽量:
ThinkPHP6.0升級后 使用查詢構造器和模型都沒有了提示
原因是tp6源碼中沒有添加注釋
找到Model.php
添加
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | * @method Query where(mixed $field , string $op = null, mixed $condition = null) static 查詢條件 * @method Query whereTime(string $field , string $op , mixed $range = null) static 查詢日期和時間 * @method Query whereBetweenTime(string $field , mixed $startTime , mixed $endTime ) static 查詢日期或者時間范圍 * @method Query whereBetweenTimeField(string $startField , string $endField ) static 查詢當前時間在兩個時間字段范圍 * @method Query whereYear(string $field , string $year = 'this year' ) static 查詢某年 * @method Query whereMonth(string $field , string $month = 'this month' ) static 查詢某月 * @method Query whereDay(string $field , string $day = 'today' ) static 查詢某日 * @method Query whereRaw(string $where , array $bind = []) static 表達式查詢 * @method Query whereExp(string $field , string $condition , array $bind = []) static 字段表達式查詢 * @method Query when(mixed $condition , mixed $query , mixed $otherwise = null) static 條件查詢 * @method Query join(mixed $join , mixed $condition = null, string $type = 'INNER' ) static JOIN查詢 * @method Query view(mixed $join , mixed $field = null, mixed $on = null, string $type = 'INNER' ) static 視圖查詢 * @method Query with(mixed $with ) static 關聯預載入 * @method Query count (string $field ) static Count 統計查詢 * @method Query min(string $field ) static Min統計查詢 * @method Query max(string $field ) static Max統計查詢 * @method Query sum(string $field ) static SUM統計查詢 * @method Query avg(string $field ) static Avg統計查詢 * @method Query field(mixed $field , boolean $except = false) static 指定查詢字段 * @method Query fieldRaw(string $field , array $bind = []) static 指定查詢字段 * @method Query union(mixed $union , boolean $all = false) static UNION查詢 * @method Query limit(mixed $offset , integer $length = null) static 查詢LIMIT * @method Query order(mixed $field , string $order = null) static 查詢ORDER * @method Query orderRaw(string $field , array $bind = []) static 查詢ORDER * @method Query cache(mixed $key = null, integer $expire = null) static 設置查詢緩存 * @method mixed value(string $field ) static 獲取某個字段的值 * @method array column(string $field , string $key = '' ) static 獲取某個列的值 * @method Model find(mixed $data = null) static 查詢單個記錄 不存在返回Null * @method Model findOrEmpty(mixed $data = null) static 查詢單個記錄 不存在返回空模型 * @method \think\model\Collection select(mixed $data = null) static 查詢多個記錄 * @method Model withAttr( array $name , \Closure $closure ) 動態定義獲取器 |
找到DbManager.php
添加
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | * Class DbManager * @package think * @mixin BaseQuery * @mixin Query * @method \think\db\Query master() static 從主服務器讀取數據 * @method \think\db\Query readMaster(bool $all = false) static 后續從主服務器讀取數據 * @method \think\db\Query table(string $table ) static 指定數據表(含前綴) * @method \think\db\Query name(string $name ) static 指定數據表(不含前綴) * @method \think\db\Query where(mixed $field , string $op = null, mixed $condition = null) static 查詢條件 * @method \think\db\Query whereRaw(string $where , array $bind = []) static 表達式查詢 * @method \think\db\Query whereExp(string $field , string $condition , array $bind = []) static 字段表達式查詢 * @method \think\db\Query when(mixed $condition , mixed $query , mixed $otherwise = null) static 條件查詢 * @method \think\db\Query join(mixed $join , mixed $condition = null, string $type = 'INNER' ) static JOIN查詢 * @method \think\db\Query view(mixed $join , mixed $field = null, mixed $on = null, string $type = 'INNER' ) static 視圖查詢 * @method \think\db\Query field(mixed $field , boolean $except = false) static 指定查詢字段 * @method \think\db\Query fieldRaw(string $field , array $bind = []) static 指定查詢字段 * @method \think\db\Query union(mixed $union , boolean $all = false) static UNION查詢 * @method \think\db\Query limit(mixed $offset , integer $length = null) static 查詢LIMIT * @method \think\db\Query order(mixed $field , string $order = null) static 查詢ORDER * @method \think\db\Query orderRaw(string $field , array $bind = []) static 查詢ORDER * @method \think\db\Query cache(mixed $key = null , integer $expire = null) static 設置查詢緩存 * @method \think\db\Query withAttr(string $name ,callable $callback = null) static 使用獲取器獲取數據 * @method mixed value(string $field ) static 獲取某個字段的值 * @method array column(string $field , string $key = '' ) static 獲取某個列的值 * @method mixed find(mixed $data = null) static 查詢單個記錄 * @method mixed select(mixed $data = null) static 查詢多個記錄 * @method integer insert( array $data , boolean $replace = false, boolean $getLastInsID = false, string $sequence = null) static 插入一條記錄 * @method integer insertGetId( array $data , boolean $replace = false, string $sequence = null) static 插入一條記錄并返回自增ID * @method integer insertAll( array $dataSet ) static 插入多條記錄 * @method integer update( array $data ) static 更新記錄 * @method integer delete (mixed $data = null) static 刪除記錄 * @method boolean chunk(integer $count , callable $callback , string $column = null) static 分塊獲取數據 * @method \Generator cursor(mixed $data = null) static 使用游標查找記錄 * @method mixed query(string $sql , array $bind = [], boolean $master = false, bool $pdo = false) static SQL查詢 * @method integer execute(string $sql , array $bind = [], boolean $fetch = false, boolean $getLastInsID = false, string $sequence = null) static SQL執行 * @method \think\Paginator paginate(integer $listRows = 15, mixed $simple = null, array $config = []) static 分頁查詢 * @method mixed transaction(callable $callback ) static 執行數據庫事務 * @method void startTrans() static 啟動事務 * @method void commit() static 用于非自動提交狀態下面的查詢提交 * @method void rollback() static 事務回滾 * @method boolean batchQuery( array $sqlArray ) static 批處理執行SQL語句 * @method string getLastInsID(string $sequence = null) static 獲取最近插入的ID |
代碼提示效果:
RELATED RECOMMEND