我正在使用 CakePHP 1.2,我只是想知道将 $this->data 从控制器传递到视图是否有任何副作用。
前任:
// inside PostsController, I have this code:
$this->data['Posts'] = $this->Post->find('all');
代替 :
$posts = $this->Post->find('all');
$this->set(compact('posts'));
// inside the /posts/view, I access it like this:
<?php foreach ($this->data['Posts'] as $post) {....};?>
通过这样做,我从控制器中跳过了 $this->set() 。这是否违反了任何 MVC 模式或我可能忽略的任何安全问题?我看到使用 Auth 组件,$this->data 包含 [_Token] 数组。
谢谢