test

CakePHP Note

Read(詳細)

UPDATE:2008.04.09

モデルのreadメソッドで単一レコードのデータを読み出し、setメソッドでビューにデータを渡します。

class PostsController extends AppController {
    var $name = 'Posts';
    
    function view($id = null) {
        if (!$id) {
            $this->Session->setFlash(__('Invalid Post.', true));
            $this->redirect(array('action'=>'index'));
        }
        $this->set('post', $this->Post->read(null, $id));
    }
}