<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                要使用Db類必須使用門面方式(`think\facade\Db`)調用助手函數在5.2被移除了 第二種方式是通過容器獲取:`$db=app("db");` >[danger]新版的數據庫和模型操作已經獨立為[`ThinkORM`](https://github.com/top-think/think-orm)庫,默認安裝應用的時候會自動安裝,如果你不需要使用該`ORM`庫的話,可以單獨卸載`topthink/think-orm`后安裝其它的`ORM`庫。 ~~~ Query基類類BaseQuery __call(string $method, array $args) 利用__call方法實現一些特殊的Model方法 newQuery(): BaseQuery 創建一個新的查詢對象 getConnection():ConnectionInterface 獲取當前的數據庫Connection對象 name($name):this 指定默認的數據表名(不含前綴) getName(): string 獲取當前的數據表名稱 getConfig(string $name = ''):mixed 獲取數據庫的配置參數 getTable(string $name = ''):mixed 得到當前或者指定名稱的數據表 setFieldType(array $type):this 設置字段類型信息 getLastSql(): string 獲取最近一次查詢的sql語句 getNumRows(): int 獲取返回或者影響的記錄數 getLastInsID(string $sequence = null) 獲取最近插入的ID value(string $field, $default = null):mixed 得到某個字段的值 column(string $field, string $key = ''): array 得到某個列的數組 union($union, bool $all = false):this 查詢SQL組裝 union unionAll($union):this 查詢SQL組裝 union all field($field):this 指定查詢字段 withoutField($field):this 指定要排除的查詢字段 tableField($field, string $tableName, string $prefix = '', string $alias = ''):this 指定其它數據表的查詢字段 data(array $data):this 設置數據 removeOption(string $option = ''):this 去除查詢參數 limit(int $offset, int $length = null):this 指定查詢數量 page(int $page, int $listRows = null): 指定分頁 table($table):this 指定當前操作的數據表 order($field, string $order = ''):this 指定排序 order('id','desc') 或者 order(['id'=>'desc','create_time'=>'desc']) paginate($listRows = null, $simple = false): Paginator 分頁查詢 paginateX($listRows = null, string $key = null, string $sort = null): Paginator 根據數字類型字段進行分頁查詢(大數據) more(int $limit, $lastId = null, string $key = null, string $sort = null): array 根據最后ID查詢更多N個數據 cache($key = true, $expire = null, $tag = null):this 查詢緩存 lock($lock = false):this 指定查詢lock alias($alias):this 指定數據表別名 master(bool $readMaster = true):this 設置從主服務器讀取數據 strict(bool $strict = true):this 設置是否嚴格檢查字段名 sequence(string $sequence = null):this 設置自增序列名 json(array $json = [], bool $assoc = false):this 設置JSON字段信息 pk($pk):this 指定數據表主鍵 getOptions(string $name = ''):mixed 獲取當前的查詢參數 setOption(string $option, $value):this 設置當前的查詢參數 via(string $via = ''):this 設置當前字段添加的表別名 save(array $data = [], bool $forceInsert = false):integer 保存記錄 自動判斷insert或者update insert(array $data = [], bool $getLastInsID = false):integer|string 插入數據 參數2為true返回自增主鍵 insertGetId(array $data):integer|string 插入記錄并獲取自增ID insertAll(array $dataSet = [], int $limit = 0): int 批量插入記錄 selectInsert(array $fields, string $table): int 通過Select方式插入記錄 update(array $data = []): int 更新記錄 delete($data = null): int 刪除記錄 select($data = null): Collection 查找記錄 find($data = null):array|Model|null 查找單條記錄 parseOptions(): array 分析表達式(可用于查詢或者寫入操作) parseUpdateData(&$data): bool 分析數據是否存在更新條件 parsePkWhere($data): void 把主鍵值轉換為查詢條件 支持復合主鍵 project權限 options(array $options):this 查詢參數批量賦值 getModelUpdateCondition(array $options):?? 獲取模型的更新條件 Query類 Query extends BaseQuery orderRaw($field, array $bind = []):this 表達式方式指定Field排序 fieldRaw(string $field):this 表達式方式指定查詢字段 orderField(string $field, array $values, string $order = ''):this 指定Field排序 orderField('id',[1,2,3],'desc') orderRand():this 隨機排序 exp(string $field, string $value):this 使用表達式設置數據 tableRaw(string $table):this 表達式方式指定當前操作的數據表 query(string $sql, array $bind = []): array 執行查詢 返回數據集 execute(string $sql, array $bind = []): int 執行語句 fetchSql(bool $fetch = true):$this|Fetch 獲取執行的SQL語句而不進行實際的查詢 為true 返回sql batchQuery(array $sql = []): bool 批處理執行SQL語句(批處理的指令都認為是execute操作) using($using):this USING支持 用于多表刪除 procedure(bool $procedure = true):this 存儲過程調用 group($group):this 指定group查詢 having(string $having):this 指定having查詢 distinct(bool $distinct = true):this 指定distinct查詢 force(string $force):this 指定強制索引 comment(string $comment):this 查詢注釋 replace(bool $replace = true):this 設置是否REPLACE partition($partition):this 設置當前查詢所在的分區 duplicate($duplicate):this 設置DUPLICATE extra(string $extra):this 設置查詢的額外參數 buildSql(bool $sub = true): string 創建子查詢SQL getPk():string|array 獲取當前數據表的主鍵 autoinc(string $autoinc):this 指定數據表自增主鍵 getAutoInc():string|null 獲取當前數據表的自增主鍵 inc(string $field, float $step = 1):this 字段值增長 dec(string $field, float $step = 1):this 字段值減少 getQueryGuid($data = null): string 獲取當前的查詢標識 getPdo(): PDOStatement 執行查詢但只返回PDOStatement對象 cursor($data = null):\Generator 使用游標查找記錄 chunk(int $count, callable $callback, $column = null, string $order = 'asc'): bool 分批數據返回處理 ~~~ **BaseQuery 引用了如下trait類** use concern\TimeFieldQuery;//時間查詢 use concern\AggregateQuery;//聚合查詢 use concern\ModelRelationQuery;//模型及關聯查詢 use concern\ResultOperation;//查詢數據處理 use concern\Transaction;//事務支持 use concern\WhereQuery;//條件支持 **Query引用了如下trait類** use concern\JoinAndViewQuery;//JOIN和VIEW查詢 use concern\ParamsBind;//參數綁定 use concern\TableFieldInfo;//數據字段信息 ## **trait JoinAndViewQuery:JOIN和VIEW查詢** \vendor\topthink\think-orm\src\db\concern\JoinAndViewQuery.php ``` join($join="關聯的表名:", string $condition = 條件:null, string $type = 'JOIN類型:INNER', array $bind = 參數綁定:[]):this 查詢SQL組裝 join leftJoin($join, string $condition = null, array $bind = []) LEFT JOIN rightJoin($join, string $condition = null, array $bind = []) RIGHT JOIN fullJoin($join, string $condition = null, array $bind = []) FULL JOIN view($join="數據表:", $field = 查詢字段:true, $on = JOIN條件:null, string $type = 'JOIN類型:INNER', array $bind = 參數綁定:[]) 指定JOIN查詢字段 //示例: Db::view('User', 'id,name') ->view('Profile', 'truename,phone,email', 'Profile.user_id=User.id', 'LEFT') ->view('Score', 'score', 'Score.user_id=Profile.id', 'RIGHT') ->where('score', '>', 80) ->select(); //User.name,Profile.truename,Profile.phone,Profile.email,Score.score FROM think_user User LEFT JOIN think_profile Profile ON Profile.user_id=User.id RIGHT JOIN think_socre Score ON Score.user_id=Profile.id WHERE Score.score > 80 ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看