Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
class Users_IndexController extends Zend_Controller_Action
{
public function indexAction()
{
$this->view->user = new Users_Model_User();
}
}
class Users_ProfileController extends Zend_Controller_Action
{
protected $user;
public function init()
{
$this->user = new Users_Model_User();
if (!$this->user->find( $this->_getParam('id') )) {
return $this->_forward( /* 404 Not found */ );
}
}
public function indexAction()
{
$this->view->user = $this->user;
}
public function editAction()
{
$form = new Users_Form_User();
$this->view->form = $form;
$form->populate( $this->user->getOptions() );
if (!$this->getRequest()->isPost()) {
return;
}
if (!$form->isValid( $this->getRequest()->getPost() )) {
return;
}
$this->user->setOptions( $form->getValues() );
$this->user->save();
$this->_forward('index');
}
}
Zend_Db – объекты модели, связи и сложные условия