Zend Framework Cheat Sheet
Zend Framework Cheat Sheet
Zend_Controller Zend_Db/Zend_Db_Table
// fetch user id from GET or POST // we only return one row here
$uid = $this->getRequest()->getParam('uid'); return $this->fetchRow($select);
$this->view->activationForm = $this->_getActivationForm(); }
// check if the request is POST (so the form is submitted) public function activate($uid) {
if ($this->getRequest()->isPost()) {
$where = $this->getAdapter()->quoteInto('uid = ?', $uid,
// validate the form values and assign error messages (if not valid) 'INTEGER');
if ($this->view->activationForm->isValid($_POST)) {
$this->update(array(
// get the filtered values of the activation form 'active' => 1,
$values = $this->view->activationForm->getValues(); 'registered_on' => new Zend_Db_Expr('NOW()')
), $where);
$userTable = new User();
$userTable->activate($values['uid']); }
}
// display another view with success message
$this->render('activationComplete');
}
else {
$this->view->activationForm->setDescription('Your account could
not be activate. Please correct the form values.');
}
}
}
}
Zend_Registry Zend_View/Zend_Layout
// get the sitewide database adapter // Layout deaktivieren
$db = Zend_Registry::get('db'); $this->getHelper('layout')->disableLayout();
© www.ideveloper.de