public function register($email, $password) { $userDb = new Shared_Db_Table_User(); try { $userDb->getAdapter()->beginTransaction(); $userId = $userDb->insert(array('email' => $email, 'password' => md5($password), 'created' => new Zend_Db_Expr('NOW()'))); $userDb->getAdapter()->commit(); } catch (Exception $e) { $userDb->getAdapter()->rollBack(); throw $e; } return $userId; }
public function viewAction() { if ($this->view->identity === null) { throw new Www_Exception_Auth(); } $id = $this->_getParam('id'); $userDb = new Shared_Db_Table_User(); $user = $userDb->fetchRow(array('id = ?' => $id)); if ($user === null) { throw new Www_Exception_NotFound(); } if ($user->id != $this->view->identity->id) { throw new Www_Exception_Access(); } $this->view->user = $user; // get this user's applications $applicationDb = new Shared_Db_Table_Application(); $select = $applicationDb->select()->setIntegrityCheck(false)->from('application')->joinLeft('template', 'application.id = template.application_id', array('template_count' => 'COUNT(*)'))->where('application.user_id = ?', $user->id)->group('application.id')->order('application.created DESC'); $this->view->applications = $applicationDb->fetchAll($select); }