1、Zend Freamwork 配置源码配置目录Zend 框架就放在library中。根目录.htaccess 文件内容RewriteEngine onRewriteRule .* index.phpphp_flag magic_quotes_gpc offphp_flag register_globals offapplication 目录下.htaccess文件内容deny from allindex.php 127.0.0.1, username = root, password = root, dbname = zend, charset= utf8 );$db = Zend_Db:fa
2、ctory(PDO_MYSQL,$params);Zend_Db_Table:setDefaultAdapter($db);/设置控制器$frontContraller = Zend_Controller_Front:getInstance();$frontContraller - throwExceptions(true);$frontContraller - setControllerDirectory(./application/controllers);/Acl$acl = new Zend_Acl();$acl-addRole(new Zend_Acl_Role(guest);$ac
3、l-addRole(new Zend_Acl_Role(user),guest);$acl-addRole(new Zend_Acl_Role(admin),user);$acl-add(new Zend_Acl_Resource(index);$acl-add(new Zend_Acl_Resource(work);$acl-add(new Zend_Acl_Resource(admin);$acl-allow(guest,index);$acl-allow(user,work);$acl-allow(admin);$privalege = $acl-isAllowed(guest,inde
4、x) ? allow : denied;if($privalege = denied) exit(Denied);/$frontContraller -dispatch();?_IndexController.phpinitView(); $this-view-baseUrl = $this-_request-getBaseUrl(); Zend_Loader:loadClass(Album); function indexAction() $this-view-title = My Albums; $album = new Album(); $this-view-albums = $albu
5、m-fetchAll(); $this-render(); function addAction() $this-view-title = Add New Albums; if(strtolower($_SERVERREQUEST_METHOD) = post) Zend_Loader:loadClass(Zend_Filter_StripTags); $filter = new Zend_Filter_StripTags(); $artist = $filter-filter($this-_request-getPost(artist); $artist = trim($artist); $
6、title = $filter-filter($this-_request-getPost(title); $title = trim($title); if($artist != & $title != ) $data = array( artist = $artist, title = $title, ); $album = new Album(); $album-insert($data); $this-_redirect(./); return; $this-view-album = new stdClass(); $this-view-album-id = null; $this-v
7、iew-album-artist = ; $this-view-album-title = ; $this-view-action = add; $this-view-buttonText = Add; $this-render(); function editAction() $this-view-title = Edit new Album; $album = new Album(); if(strtolower($_SERVERREQUEST_METHOD) = post) Zend_Loader:loadClass(Zend_Filter_StripTags); $filter = n
8、ew Zend_Filter_StripTags(); $id = (int)$this-_request-getPost(id); $artist = $filter-filter($this-_request-getPost(artist); $artist = trim($artist); $title = $filter-filter($this-_request-getPost(title); $title = trim($title); if($id != false) $data = array( artist = $artist, title = $title, ); $whe
9、re = id = .$id; $album-update($data,$where); $this-_redirect(./); return; else $this-view-album = $album-fetchRow(id=.$id); else $id = (int)$this-_request-getParam(id,0); if($id 0) $this-view-album = $album-fetchRow(id=.$id); $this-view-action = edit; $this-view-buttonText = Update; $this-render();
10、function deleteAction() $this-view-title = Delete New Album; $album = new Album(); if(strtolower($_SERVERREQUEST_METHOD) = post) Zend_Loader:loadClass(Zend_Filter_Alpha); $filter = new Zend_Filter_Alpha(); $id = (int)$this-_request-getPost(id); $del = $filter-filter($this-_request-getPost(del); if($
11、del = Yes & $id 0) $where = id = .$id; $rows_affected = $album-delete($where); else $id = (int)$this-_request-getParam(id); if($id 0) $this-view-album = $album-fetchRow(id = .$id); if($this-view-album-id 0) $this-render(); return; $this-_redirect(./); ?_index.phtmlescape($this-title);?a href=baseUrl
12、;?/index/addAdd new albun Title Artist albums AS $album) :? escape($album-title);? escape($album-artist);? a href=baseUrl;?/index/edit/id/id;?Edit a href=baseUrl;?/index/delete/id/id;?Delete _header.phtml escape($this-title);? link rel=stylesheet type=text/css href=baseUrl;?/public/styles/sit
13、e.css / _footer.phtml edit.phtmlescape($this-title);?delete.phtmlescape($this-title);?album):?form action=baseUrl ?/index/delete method=post Arre you sure that you want to delete escape($this-album-title);? By escape($this-album-artist);? ? input type=hidden name=id value=escape($this-album-id);? /
14、Cannot find album.add.pthmlescape($this-title);?_form.phtmlform action=baseUrl;?/index/action;? method=post Artist input type=text name=artist value=escape($this-album-artist);?/ Title input type=text name=title value=escape($this-album-title);?/input type=hidden name=id value=escape($this-album-id)
15、;?/input type=submit name=add value=escape($this-buttonText);? /Album.phpMySQL- phpMyAdmin SQL Dump- version 3.3.10- - 主机: localhost- 生成日期: 2011 年 09 月 29 日 03:15- 服务器版本: 5.5.8- PHP 版本: 5.3.5SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;- 数据库: zend- - 表的结构 album-CREATE TABLE IF NOT EXISTS album ( id int(10) unsigned NOT NULL AUTO_INCREMENT, artist varchar(100) NOT NULL, title varchar(100) NOT NULL, PRIMARY KEY (id) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;- 转存表中的数据 album-INSERT INTO album (id, artist, title) VALUES(1, kylin, 你好13),(2, yeleng, 我想你),(5, SZH, ILY);
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1