星期二, 4月 27, 2010

zend 建立CRUD

Zend Framework version: 1.10
參考:Tutorial: Getting Started with Zend Framework 1.10

針對IndexController建立CRUD action
URLAction method
http://localhost/public/IndexController::indexAction()
http://localhost/add /IndexController::addAction()
http://localhost/edit /IndexController::editAction()
http://localhost/delete /IndexController::deleteAction()
分別輸入以下指令:
  • %zf create action add Index
  • %zf create action edit Index
  • %zf create action delete Index
這時除了建立各action的page外,還會自動在IndexController建立各action的動作
所以說如果是要針對UserController,最後的Index就改成User
以下是IndexController的內容
//controllers/IndexController.php
class IndexController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}

public function indexAction()
{
// action body
}

public function addAction()
{
// action body
}

public function editAction()
{
// action body
}

public function deleteAction()
{
// action body
}
}

沒有留言: