<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之旅 廣告
                ### **model屬性** | 屬性名 | 默認值 | 描述 | 類型 | | --- | --- | --- | --- | | | <h2>屬性</h2> | | | | $links| [] | 數據庫查詢對象池(靜態屬性) | array| | $connection | []| 數據庫配置 | array | | $parent| none | 父關聯模型對象 | object | | $query| none | 數據庫查詢對象 | object | | $name | none | 模型名稱(不加前綴) | string | | $table | none | 數據表名稱(需要加前綴) | string | | $class | none | 當前類名稱 | string | | $event | [] | 回調事件 | array | | $error| none | 錯誤信息| string| | $validate| none | 字段驗證規則 | array| | $pk| none | 數據表主鍵 復合主鍵使用數組定義 不設置則自動獲取 | string| | $field| []| 數據表字段信息 留空則自動獲取 | array | | $except| [] | 數據排除字段 | array| | $readonly| []| 只讀字段 | array | | $visible| []| 顯示屬性 | array | | $hidden| []| 隱藏屬性 | array | | $append| []| 追加屬性 | array | | $data| []| 數據信息 | array | | $origin| []| 原始數據 | array | | $relation| []| 關聯模型 | array | | $auto| []| 保存自動完成列表 | array | | $insert| []| 新增自動完成列表 | array | | $update| []| 更新自動完成列表 | array | | $autoWriteTimestamp| none| 是否需要自動寫入時間戳 如果設置為字符串 則表示時間字段的類型 | bool或者string| | $createTime| 'create_time'| 創建時間字段 | string | | $updateTime| 'update_time' | 更新時間字段 | string| | $dateFormat| none| 時間字段取出后的默認時間格式 | ?? | | $type| []| 字段類型或者格式轉換 | array | | $isUpdate| false | 是否為更新數據 | bool| | $replace| false| 是否使用Replace | bool| | $force| false | 是否強制更新所有數據 | bool| | $updateWhere| none| 更新條件 | ??| | $failException| false | 驗證失敗是否拋出異常 | bool| | $useGlobalScope| true| 是全局查詢范圍 | bool| | $batchValidate| false | 是否采用批量驗證 | bool| | $resultSetType| none| 查詢數據集對象 | object| | $relationWrite| none | 關聯自動寫入 | ??| | $initialized| [] | 初始化過的模型 | array | | $readMaster| none | 是否從主庫讀取(靜態屬性)(主從分布式有效) | array | ### **model方法** | 方法名(public) | 描述 | 參數 | 返回值| | --- | --- | --- | ---| | | <h2>方法</h2> | | | | readMaster | 是否從主庫讀取數據(主從分布有效) | ($all = false) |this| | newInstance | 創建新的模型實例 | ($data = [], $isUpdate = false, $where = null) | Model | | getQuery| 獲取當前模型的查詢對象 | ($buildNewQuery = false) | Query| | db | 獲取當前模型的數據庫查詢對象 | ($useBaseQuery = true, $buildNewQuery = true) |Query| | setParent | 設置父關聯對象 | ($model) | this | | getParent | 獲取父關聯對象 | void | Model | | data | 設置數據對象值 | ($data, $value = null) | this | | getData | 獲取對象原始數據 如果不存在指定字段返回false | ($name = null) | mixed | | isAutoWriteTimestamp | 是否需要自動寫入時間字段 |($auto) | this | | force | 新是否強制寫入數據 而不做比較 | ($force = true) | this | | setAttr | 修改器 設置數據對象值 | ($name, $value, $data = []) | this | | getRelation | 獲取當前模型的關聯模型數據 | ($name = null)| mixed | | setRelation | 設置關聯數據對象值 | ($name, $value) | this | | getAttr| 獲取器 獲取數據對象的值;如果存在`'get'.$name.'Attr'`方法則調用它,否則查看type屬性里是否以鍵的形式存在,存在即轉換類型,否則查看是是createTime和updateTime屬性的值,是則轉換時間格式,否則將$name當做關聯方法執行(該屬性為駝峰或小寫+下劃線格式都可以,最后都會轉化為駝峰格式執行) | ($name) | mixed | | append | 設置需要追加的輸出屬性 | ($append = [], $override = false) | this | | appendRelationAttr | 設置附加關聯對象的屬性 | ($relation, $append) | this | | hidden | 設置需要隱藏的輸出屬性 | ($hidden = [], $override = false) | this | | visible | 設置需要輸出的屬性 | ($visible = [], $override = false) | this | | toArray | 轉換當前模型對象為數組 | void | array | | toJson | 轉換當前模型對象為JSON字符串 | ($options = JSON_UNESCAPED_UNICODE) | string | | removeRelation | 移除當前模型的關聯屬性 | void | this | | toCollection | 轉換當前模型數據集為數據集對象 | ($collection) | \think\Collection | | together | 關聯數據一起更新 | ($relation) | this | | getPk | 獲取模型對象的主鍵 | ($name{模型名} = '') | mixed | | replace | 新增數據是否使用Replace | ($replace = true) | this | | **save** | 保存當前數據對象 | ($data = [], $where = [], $sequence = null) | integer\|false | | getChangedData | 獲取變化的數據 并排除只讀數據 | void | array | | setInc | 字段值(延遲)增長 | ($field, $step = 1, $lazyTime = 0) | integer\|true | | setDec | 字段值(延遲)遞減 | ($field, $step = 1, $lazyTime = 0) | integer\|true | | **saveAll** | 保存多個數據到當前數據對象 | ($dataSet, $replace = true) | array\|false | | allowField | 設置允許寫入的字段 | ($field) | this | | except | 設置排除寫入的字段 | ($field) | this | | readonly | 設置只讀字段 | ($field) | this | | isUpdate | 是否為更新數據 | ($update = true, $where = null) | this | | **delete** | 刪除當前的記錄 | void | integer | | auto | 設置自動完成的字段( 規則通過修改器定義) | ($fields) | this | | validate | 設置字段驗證 | ($rule = true, $msg = [], $batch = false) | this | | validateFailException | 設置驗證失敗后是否拋出異常 | ($fail = true) | this | | getError | 返回模型的錯誤信息 | void | string\|array | | event | 注冊回調方法 | ($event, $callback, $override = false) | void | | **create** | 寫入數據(靜態方法) | ($data = [], $field = null) | this | | **update** | 更新數據(靜態方法) | ($data = [], $where = [], $field = null) | this | | **get** | 查找單條記錄(靜態方法) | ($data, $with = [], $cache = false)<br>$data 主鍵值或者查詢條件(閉包)<br>$with 關聯預查詢 | static[]\|false (**注**:static返回最終運行的那個子類模型對象) | | **all** | 查找所有記錄(靜態方法) | ($data = null, $with = [], $cache = false) | static[]\|false | | **destroy** | 刪除記錄(靜態方法) | ($data) | integer | | scope | 命名范圍(靜態方法) | ($name) | Query | | useGlobalScope | 設置是否使用全局查詢范圍(靜態方法) | ($use{布爾}) | Query | | has | 根據關聯條件查詢當前模型(靜態方法) | ($relation, $operator = '>=', $count = 1, $id = '*') | Relation\|Query | | hasWhere | 根據關聯條件查詢當前模型(靜態方法) | ($relation, $where = [], $fields = null) | Relation\|Query | | relationQuery | 查詢當前模型的關聯數據 | ($relations) | this | | eagerlyResultSet | 預載入關聯查詢 返回數據集 | (&$resultSet, $relation) | array | | eagerlyResult | 預載入關聯查詢 返回模型對象 | (&$result, $relation) | Model | | relationCount | 關聯統計 | (&$result, $relation) | void | | **hasOne** | HAS ONE 關聯定義 | ($model, $foreignKey = '', $localKey = '', $alias = [], $joinType = 'INNER') | HasOne | | **belongsTo** | BELONGS TO 關聯定義 | ($model, $foreignKey = '', $localKey = '', $alias = [], $joinType = 'INNER') | BelongsTo | | **hasMany** | HAS MANY 關聯定義 | ($model, $foreignKey = '', $localKey = '') | HasMany | | **hasManyThrough** | HAS MANY 遠程關聯定義 | ($model, $through, $foreignKey = '', $throughKey = '', $localKey = '') | HasManyThrough | | **belongsToMany** | BELONGS TO MANY 關聯定義 | ($model, $table = '', $foreignKey = '', $localKey = '') | BelongsToMany | | **morphMany** | ORPH MANY 關聯定義 | ($model, $morph = null, $type = '') | MorphMany | | **morphOne** | MORPH One 關聯定義 | ($model, $morph = null, $type = '') | MorphOne | | **morphTo** | MORPH TO 關聯定義 | ($morph = null, $alias = []) | MorphTo | | __call | 調用當前類不存在或者不可訪問的方法時<br>比如:<br>調用model('user')->test('hello')test在當前模型或者model類中不存在,那么查找是否有scop_test('hello'),如果還不存在則調用Query對象里的test方法,Query還不存在,那就查看方法是否是getby+字段名(如getbyusername('tom'),那就是查詢username為tom的數據即**動態查詢**,如果還找不到則報錯) | ($method, $args) | | | __callStatic | 調用當前類不存在或者不可訪問的靜態方法時觸發,用法同__call | ($method, $args) | | | __isset | 調用當前類不存在或者不可訪問的屬性使用isset() 或者empty()時觸發,一般用來在模型中調用表字段 | | | | __unset | 當對不可訪問的屬性說那個unset()時觸發,銷毀數據對象的值 | ($name) | | | __toString | 當model對象被當做字符串時觸發,將類對象轉為json?;如echo model('user') | | | | jsonSerialize | 實現 JsonSerializable 接口 調用 json_encode() 時觸發(對模型對象使用json_encode時觸發),轉成數組?| | | | offsetSet | 實現ArrayAccess的方法 ,以數組的方式設置模型屬性時觸發如:$user['data'] = $data;觸發setAttr方法 | | | | offsetExists | 實現ArrayAccess的方法 isset($user['data'])時觸發__isset方法 | | | | offsetUnset | 實現ArrayAccess的方法 unset($user['data'])時觸發__unset方法 | | | | offsetGet | 實現ArrayAccess的方法 $user['data']時觸發getAttr方法 | | | | __set | 設置不存在的屬性時觸發修改器,存在【get字段名Attr】則返回字段值,不存在則查詢關聯數據并保存 | $name, $value) | void | | __get | 調用不存在的屬性時觸發獲取器getAttr() | ($name) | void | | | | | | ## -----------------------------------------模型事件快捷方法(都為靜態方法)-------------------------------------------------------- beforeInsert($callback, $override = false) afterInsert($callback, $override = false) beforeUpdate($callback, $override = false) afterUpdate($callback, $override = false) beforeWrite($callback, $override = false) afterWrite($callback, $override = false) beforeDelete($callback, $override = false) afterDelete($callback, $override = false) ## **HasOne** | 屬性名 | 默認值 | 描述 | 類型 | | --- | --- | --- | --- | | | <h2>屬性</h2> | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 方法名(public) | 描述 | 參數 | 返回值| | --- | --- | --- | ---| | | <h2>方法</h2> | | | | | | | | | | | | | | | | | | | | | | | kasOne與BelongsTo繼承至OneToOne OneToOne、HasMany、HasManyThrough、BelongsToMany、MorphMany、MorphOne、MorphOne、MorphTo繼承至Relation ## **Relation** | 方法名(public) | 描述 | 參數 | 返回值| | --- | --- | --- | ---| | | <h2>方法</h2> | | | | getParent | 獲取關聯的所屬模型 | void | Model | | getModel | 獲取當前的關聯模型對象實例 | void | Model | | getQuery | 獲取關聯的查詢對象 | void | Query | | selfRelation | 設置當前關聯為自關聯 | ($self = true) | this | | isSelfRelation | 當前關聯是否為自關聯 | void | bool | | __call | 獲取Query中的方法 | ($method, $args) | mixed | | | | | | | | | | | ## **OneToOne** | 方法名(public) | 描述 | 參數 | 返回值| | --- | --- | --- | ---| | | <h2>方法</h2> | | | | joinType | 設置join類型 | ($type) | this | | eagerly | 預載入關聯查詢(JOIN方式) | (Query $query, $relation, $subRelation, $closure, $first) | void | | eagerlyResultSet | 預載入關聯查詢(數據集) | (&$resultSet, $relation, $subRelation, $closure) | void | | eagerlyResult | 預載入關聯查詢(數據) | (&$result, $relation, $subRelation, $closure) | void | | save | 保存(新增)當前關聯數據對象 | ($data) | Model\|false | | setEagerlyType | 設置預載入方式 | ($type) | this | | getEagerlyType | 獲取預載入方式 | void | integer | | bind | 綁定關聯表的屬性到父模型屬性 | ($attr) | this | | getBindAttr | 獲取綁定屬性 | void | array | | relationCount | 關聯統計 | ($result, $closure) | integer | ## **HasOne** | 方法名(public) | 描述 | 參數 | 返回值| | --- | --- | --- | ---| | | <h2>方法</h2> | | | | getRelation | 延遲獲取關聯數據 | ($subRelation = '', $closure = null) | array\|false\|\PDOStatement\|string\|Model | | has | 根據關聯條件查詢當前模型 | void | Query | | hasWhere | 根據關聯條件查詢當前模型 | ($where = [], $fields = null) | Query | ## **BelongsTo** | 方法名(public) | 描述 | 參數 | 返回值| | --- | --- | --- | ---| | | <h2>方法</h2> | | | | getRelation | 延遲獲取關聯數據 | ($subRelation = '', $closure = null) | array\|false\|\PDOStatement\|string\|Model | | has | 根據關聯條件查詢當前模型 | void | Query | | hasWhere | 根據關聯條件查詢當前模型 | ($where = [], $fields = null) | Query | | associate | 添加關聯數據 | e($model) | Model | | dissociate | 注銷關聯數據 | void | Model | ## **HasMany** | 方法名(public) | 描述 | 參數 | 返回值| | --- | --- | --- | ---| | | <h2>方法</h2> | | | | getRelation | 延遲獲取關聯數據 | ($subRelation = '', $closure = null) | array\|false\|\PDOStatement\|string\|Model | | has | 根據關聯條件查詢當前模型 | void | Query | | hasWhere | 根據關聯條件查詢當前模型 | ($where = [], $fields = null) | Query | | eagerlyResultSet | 預載入關聯查詢 | (&$resultSet, $relation, $subRelation, $closure) | void | | eagerlyResult | 預載入關聯查詢 | (&$result, $relation, $subRelation, $closure) | void | | relationCount | 關聯統計 | ($result, $closure) | integer | | getRelationCountQuery | 創建關聯統計子查詢 | ($closure, &$name = null) | string | | save | 保存(新增)當前關聯數據對象 | ($data) | Model\|false | | make | 創建關聯對象實例 | ($data = []) | Model | | saveAll | 批量保存當前關聯數據對象 | (array $dataSet) | integer | ## **xxx** | 方法名(public) | 描述 | 參數 | 返回值| | --- | --- | --- | ---| | | <h2>方法</h2> | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ## **xxx** | 方法名(public) | 描述 | 參數 | 返回值| | --- | --- | --- | ---| | | <h2>方法</h2> | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ## **xxx** | 方法名(public) | 描述 | 參數 | 返回值| | --- | --- | --- | ---| | | <h2>方法</h2> | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ## **xxx** | 方法名(public) | 描述 | 參數 | 返回值| | --- | --- | --- | ---| | | <h2>方法</h2> | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
                  <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>

                              哎呀哎呀视频在线观看