2012-02-11 55 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