php中的mvc

wuyuwww 2012-08-04 01:26:10
这个东西我貌似懂了点,但现在看貌似我又没懂。
下面的代码是controller下的一个类的方法
function delete_report($items = null)
{
if(!isset($this->data['id']))
{
$this->redirect(array('controller' => 'reports', 'action' => 'index'));
exit;
}

if(empty($items)) $items = $this->data['id'];

if(!is_array($items)) $items = array($items);

$result = $this->Report->find('all', array('order' => 'Report.id DESC', 'conditions' => array('Report.id' => $items)));

if(isset($this->data['confirmed']) && strcmp($this->data['confirmed'], 'true') == 0)
{
foreach($result as $r)
{
$id = $r['Report']['id'];
if($id == 1) continue;

$this->Report->delete($id);
}

$this->flash("Delete report(s) successfully.", "/reports/index"); //TODO
}
else
{
$this->set('results', $result);
}
}
}


这个$this->data['id'] 是什么意思,是它接受到的表单数据吗?还是说有没有在这个类中定义这个data的属性啊?
我好迷糊啊?
不知道的千万别回答,我已经很迷糊了,头爆掉了。
...全文
143 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
tanshikao 2012-08-06
  • 打赏
  • 举报
回复
楼上说得比较清楚了,估计楼主已经明白 了
tzmacan 2012-08-05
  • 打赏
  • 举报
回复
看看这个类或者这个类的基类的初始化函数看看data数据是个什么东东
tzmacan 2012-08-05
  • 打赏
  • 举报
回复
看看这个类或者这个类的基类的初始化函数看看data数据是个什么东东
yunprince 2012-08-04
  • 打赏
  • 举报
回复
你去看看这个类或者这个类的基类的初始化函数看看data数据是个什么东东
hjyang2012 2012-08-04
  • 打赏
  • 举报
回复
对的 是定义的data属性
ci1699 2012-08-04
  • 打赏
  • 举报
回复
$this->data['id']

$this -> data 是一个数组。
也就是说有这么一个数组属性,取键名为id的值。

4,251

社区成员

发帖
与我相关
我的任务
社区描述
国内外优秀PHP框架讨论学习
社区管理员
  • Framework
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧