天天看點

【2022/01/25】thinkphp源碼無差别閱讀(二十九)

thinkphp源碼無差别閱讀(二十九)

【2022/01/25】thinkphp源碼無差别閱讀(二十九)

ORM閱讀

db/Where.plhp

  • 屬性:where、enclose
  • 構造方法:__construct
  • 設定是否添加括号:enclose
  • 解析query對象為數組:parse
  • 分析查詢表達式:parseItem
  • 修改器:__set
  • 擷取器:__get
  • 檢測數組對象的值:__isset
  • 銷毀:__unset
  • 數組式通路:offsetSet、offsetExists、offsetUnset、offsetGet

facade/Db.php

  • 擷取目前facade對應的類名:getFacadeClass

model/Collection.php

  • 延遲預載于關聯查詢:load
  • 删除:delete
  • 更新:update
  • 設定隐藏:hidden
  • 設定顯示:visible
  • 設定需要追加的屬性:append
  • 設定模型輸出場景:scene
  • 設定父模型:setParent
  • 設定擷取器:withAttr
  • 關聯屬性到目前模型:bindAttr
  • 按指定鍵整理資料:dictionary
  • 差集:diff
  • 交集:intersect

model/Pivot.php

  • 屬性:parent、autoWriteTimestamp

model/Relation.php

  • 屬性:parent、model、query、foreignKey、localKey、baseQuery、selfRelation、withLimit、withField、withoutField、default
  • 擷取關聯模型:getParent
  • 擷取query:getQuery
  • 擷取外鍵:getForeignKey
  • 擷取主鍵:getLocalKey
  • 擷取目前模型:getModel
  • 是否自關聯:isSelfRelation
  • 封裝關聯資料集:resultSetBuild
  • 擷取查詢字段:getQueryFields
  • 擷取查詢字段:getRelationQueryFields
  • 擷取查詢條件:getQueryWhere
  • 限制關聯數量:withLimit
  • 限制關聯字段:withField
  • 排除關聯字段:withoutField
  • 設定關聯資料不存在時的預設:withDefault
  • 擷取關聯資料預設值:getDefaultModel
  • 判斷閉包的參數類型:getClosureType
  • 執行基礎查詢:baseQuery
  • 動态調用:__call

計劃閱讀

[ ] framework源碼

[ ] orm源碼

[ ] helper源碼