何时使用$ this-> data vs $ this-> request-> data

pbo*_*ond 3 cakephp-2.0

我试过谷歌搜索这个问题,我无法找到这个问题的确切答案.

我知道当我想操纵我的数据时,我需要使用$ this-> request-> data,但即便如此,即使没有操作,我也看到了Cakephp 2.0网站的博客教程,可以在这里找到:http: //book.cakephp.org/2.0/en/tutorials-and-examples/blog/part-two.html

使用$ this-> request-> data.现在,如果使用$ this-> request-> data是好的做法,即使你没有操纵数据,在控制器中使用$ this-> data有什么用?

Chu*_*ess 5

$this->data已弃用.它仍然有效,因此迁移不会中断.但它最终会被删除,一切都转移到CakeRequest和CakeResponse对象.

到这里:

http://book.cakephp.org/2.0/en/appendices/2-0-migration-guide.html

并寻找:

Controller::$data
Run Code Online (Sandbox Code Playgroud)