CAKEPHP:内部联接和控制器问题

时间:2012-06-01 04:56:00

标签: cakephp controller inner-join

http://webdesign4.georgianc.on.ca/~100141468/comp2084/todo/clients

http://bin.cakephp.org/view/1402280124

第一个链接 - 添加是 - 它工作正常,但内连接不起作用。 SQL是正确的,而不是控制器中的代码。我遇到的另一个问题是未定义的操作视图。我确信它与控制器内部的内容有关。

<?php
class ClientsController extends AppController
{
    var $name = 'Clients';
    function index()
    {
        $this->set('Clients', $this->Client->find('all'));
    }
    function add()
    {
        if ($this->request->is('post')) {
            if ($this->Client->save($this->request->data)) {
                $this->Session->SetFlash('Client has been saved');
                $this->redirect(array(
                    'action' => 'index'
                ));
            } else {
                $this->Session->setFlash('Nope');
            }
        }
    }
    public function view($id = null)
    {
        $this->Client->id = $id;
        $this->set('Client', $this->Client->read(null, $id));
    }
    public function edit($id = null)
    {
        $this->Client->id = $id;
        if ($this->request->is('get')) {
            $this->request->data = $this->Client->read();
        } else {
            if ($this->Client->save($this->request->data)) {
                $this->Session->setFlash('Client has been updated.');
                $this->redirect(array(
                    'action' => 'index'
                ));
            } else {
                $this->Session->setFlash('Unable to update Client.');
            }
        }
        $this->loadModel('Employee');
        $this->set('Employees', $this->Employee->find('list', array(
            'order' => array(
                'Employee.name'
            )
        )));
        $this->set(compact('Employees'));
    }
    public function delete($id = null)
    {
        if ($this->request->is('/Clients/delete/{id}')) {
            throw new MethodNotAllowedException();
        }
        if ($this->Client->delete($id)) {
            $this->Session->setFlash('The Client with id: ' . $id . ' has been deleted.');
            $this->redirect(array(
                'action' => 'index'
            ));
        }
    }
}
?>

0 个答案:

没有答案