1. 程式人生 > >thinkphp5 模型例項化 獲得資料物件

thinkphp5 模型例項化 獲得資料物件

DB操作返回是陣列。
模型直接操作返回是物件。

//該物件共計有28個受保護屬性,必須在本類或子類中使用,外部不能直接使用
object(app\index\model\Staff)#5 (28) {

  //資料庫配置陣列
  ["connection":protected] => array(0) {
  }
  //資料庫查詢物件,負責最終完成對資料庫的操作
  ["query":protected] => NULL
  //模型名稱 ,建立時自動賦值
  ["name":protected] => string(5) "Staff"
  //與模型繫結的資料表的完整名稱(包括字首的表名,如:tp5_staff)
  ["table":protected] => NULL
  //用名稱空間表示的、當前的模型類名:Staff
  ["class":protected] => string(21) "app\index\model\Staff"
  //出錯時顯示的資訊
  ["error":protected] => NULL
  //欄位驗證規則
  ["validate":protected] => NULL
  //資料表主鍵
  ["pk":protected] => NULL
  //資料表字段名列表(與資料表對應)
  ["field":protected] => array(0) {
  }
  //只讀欄位列表
  ["readonly":protected] => array(0) {
  }
  //顯示欄位列表
  ["visible":protected] => array(0) {
  }
  //隱藏屬性欄位列表
  ["hidden":protected] => array(0) {
  }
  //追加屬性列表
  ["append":protected] => array(0) {
  }
  //與資料表字段對應的資訊列表(極其重要)
  ["data":protected] => array(0) {
  }
  //欄位修改資訊列表
  ["change":protected] => array(0) {
  }
  //自動完成列表
  ["auto":protected] => array(0) {
  }
  //新增自動完成列表
  ["insert":protected] => array(0) {
  }
  //更新自動完成列表
  ["update":protected] => array(0) {
  }
// 是否需要自動寫入時間戳 如果設定為字串 則表示時間欄位的型別
  ["autoWriteTimestamp":protected] => bool(false)
  //設定表中:建立時間欄位的名稱
  ["createTime":protected] => string(11) "create_time"
    //設定表中:更新時間欄位的名稱
  ["updateTime":protected] => string(11) "update_time"
    //設定表中:時間欄位的格式
  ["dateFormat":protected] => string(11) "Y-m-d H:i:s"
  //資料表中各欄位型別定義
  ["type":protected] => array(0) {
  }
  //是否是:更新操作
  ["isUpdate":protected] => bool(false)
  //更新條件
  ["updateWhere":protected] => NULL
  //當前執行的關聯條件
  ["relation":protected] => NULL
  //驗證失敗是否丟擲異常
  ["failException":protected] => bool(false)
//全域性查詢範圍設定
  ["useGlobalScope":protected] => bool(true)
}