2012-02-11 84 views
0

过去几天,我一直在学习Zend Framework。截至目前,我处于初级水平。Zend Framework:创建新的潜在客户

我一直在考虑一个问题陈述:

/* 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完成吗?

回答

1

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

继Zend框架快速入门(http://framework.zend.com/manual/en/learning.quickstart.intro.html),你将最终获得通过/索引/索引访问的单个应用程序

如果考虑快速启动不够,你可以按照这个链接:http://alex-tech-adventures.com/development/zend-framework.html?start=20

在那里您将找到如何使用登录,访问控制和表单来设置应用程序。

之后,你终于可以试着了解Plans_Model_Dao_Moderator::isAdmin

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

参见:What is the difference between DAO and DAL?

提供以上(亚历克斯科技历险记)链路上的教程,不使用数据映射器。这种情况下的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 
} 
+0

非常感谢它确实是有帮助的。 – 2012-02-12 05:23:24