CakePHP:如何将插入的信息显示到数据库中


CakePHP: How can be displayed the inserted information into database?

我在控制器中有以下代码:

    function add() {            
        if (!empty($this->data)) {              
            if ($this->Password->save($this->data)) {
            $this->Session->setFlash('the password I_WANT_TO_DISPLAY_THE_INSERTED_PASSWORD_HERE was added');
            $this->redirect(array('action' => 'index'));
        }
    }
}

问题是如何在视图中显示插入的信息?一条消息"密码XXX已添加到您的数据库中"。我认为数据必须从文本字段中检索。我不知道如何在cakeHP中做到这一点。

所有保存的数据始终可从$this->data数组中获得。您可以使用以下语法:

$this->data['Model']['field'];

例如,如果您将字段passwd保存到passwords表中,它应该是:

$this->Session->setFlash(
    'the password ' . $this->data['Password']['passwd'] . ' was added'
);