thinkphp源碼無差别閱讀(二十二)
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLicmbw5yN5ITOykDM3ETMwIjMwIzLcdWbp9CXyVGdzFWbvw1dhJ3LcdWbp9CXiVHbjp2cvwVbvNmLlVGdpd2Lc9CX6MHc0RHaiojIsJye.png)
ORM閱讀
DbManager.php
- 屬性:instance、config、event、listen、dbLog、queryTimes、cache、log
- 構造方法:__construct
- 注入模型對象:modelMaker
- 監聽sql:triggerSQL
- 初始化配置參數:setConfig
- 設定緩存對象:setCache
- 設定日志對象:setLog
- 記錄sql日志:log
- 擷取查詢日志:getDbLog
- 擷取配置參數:getConfig
- 建立或者切換資料庫連接配接查詢:connect
- 建立資料庫連接配接執行個體:instance
- 擷取連接配接配置:getConnectionConfig
- 建立連接配接:createConnection
- 使用表達式設定資料:raw
- 更新查詢次數:updateQueryTimes
- 重置查詢次數:clearQueryTimes
- 擷取查詢次數:getQueryTimes
- 監聽sql執行:listen
- 擷取監聽sql執行:getListen
- 注冊事件:event
- 觸發事件:trigger
- 動态調用:__call
Model.php
- 屬性:exists、force、replace、suffix、updateWhere、connection、name、key、table、initialized、defaultSoftDelete、globalScope、lazySave、db、invoker、maker、macro
- 設定服務注入:maker
- 設定方法注入:macro
- 設定db:setDb
- 設定容器對象的依賴注入方法:setInvoker
- 調用反射執行模型方法:invoke
- 擷取模型名稱:getName
- 建立新的模型執行個體:newInstance
- 設定更新條件:setUpdateWhere
- 設定資料庫連接配接:setConnection
- 擷取連接配接:getConnection
- 設定字尾:setSuffix
- 擷取字尾:getSuffix
- 擷取db:db
- 初始化模型:initialize
- 初始化處理:init
- 未知:checkData
- 未知:checkResult
- 強制更新:force
- 判斷force:isForce
- 使用replace:replace
- 重新整理模型資料:refresh
- 設定資料是否存在:exists
- 判斷資料是否存在:isExists
- 判斷模型是否為空:isEmpty
- 延遲儲存目前資料:lazySave
- 儲存目前資料對象:save
- 檢查資料是否允許寫入:checkAllowFields
- 儲存寫入資料:saveData
- 新增寫入資料:insertData
- 擷取目前更新條件:updateWhere
- 儲存多個資料到目前資料對象:saveAll
- 删除目前記錄:delete
- 寫入資料:create
- 更新:update
- 删除:destroy
- 喚醒:__wakeup
- 修改器:__set
- 擷取器:__get
- 檢測是否有:__isset
- 銷毀資料對象的值:__unset
- 數組式通路
- 設定不适用全局查詢範圍:withGlobalScope
- 切換字尾進行查詢:suffix
- 切換資料庫連接配接進行查詢:connect
- 動态調用:__call、__callStatic
- 析構方法:__destruct
計劃閱讀
[ ] framework源碼
[ ] orm源碼
[ ] helper源碼