Zend框架:创建新的潜在客户


Zend Framework: creating new lead

过去几天我一直在学习Zend框架。到目前为止,我处于初级水平。

我收到了一份问题陈述:

/* Create a new lead
 *
 * planId will be sent $_GET['planId'], the form should send the action to
 * the same page
 * a user should be logged in and he should be administrator of the plan
 *
 * @uses Plans_Model_Dao_Moderator::isAdmin
 * @throws unauthorized exception, catch the exception in error controller
 */

我已经在网站上搜索了整个Zend教程,以了解如何开始!这真的让我很紧张。。如有任何帮助,我们将不胜感激。

是否可以使用Zend_Controller_Plugin_ErrorHandler进行错误处理?

首先,您需要设置应用程序。

遵循Zend框架快速入门(http://framework.zend.com/manual/en/learning.quickstart.intro.html)您最终将得到一个可通过/index/index 访问的单个应用程序

如果您认为快速启动还不够,可以点击以下链接:http://alex-tech-adventures.com/development/zend-framework.html?start=20

在那里,您将了解如何使用登录、访问控制以及表单设置应用程序。

之后,您终于可以尝试理解Plans_Model_Dao_Moderator::isAdmin

在这种情况下,有一个不同的概念。ZF快速入门使用数据映射器作为DAL(数据访问层),与每个模型对象的DAO(数据访问对象)配合使用。

请参阅:DAO和DAL之间的区别是什么?

上面链接上提供的教程(Alex Tech Adventures),不使用数据映射器。这种情况下的DAL是Zend_Db_Table和Zend_Db_Table_Row。但是你可以在理解了整个概念之后进行调整。

因此,基本上,Plans_Model_Dao_Moderator::isAdmin将类似于:

/**
 * Check if the user has administrative rights
 * on a given plan
 * @param int $user_id
 * @param int $plan_id
 * @return bool
 */
public function isAdmin($user_id, $plan_id)
{
    // perform the the select on the data base
    // $this->dbAdapter->fetchRow($select->from('table'...
    // return $bool
}