在afterSave中,獲取關於$this
的信息的最佳方法是什麼?在模型回調中獲取模型數據的正確方法
例如。如果我debug($this->read())
,我得到了我正在使用的當前記錄(相關模型等)所需的一切。
array(
'Comment' => array(
'id' => '12',
'user_id' => '38'
'body' => 'test',
'created' => '2013-04-11 18:56:26',
'modified' => '2013-04-11 18:56:26'
),
'User' => array(
'password' => '*****',
'id' => '38',
'username' => 'example',
'created' => '2013-01-26 18:25:39',
'modified' => '2013-01-26 18:25:39',
'first_name' => '',
'last_name' => ''
)
)
但這並不意味着我再次查詢數據庫? $this
不應該已經包含了所有這些信息嗎?
什麼是得到$this->read()
的結果的正確方法,或者這是正確的方法?
+1尼斯和完整的答案 – thaJeztah 2013-04-11 20:43:21