Zend Freamwork配置源码.docx

上传人:b****4 文档编号:11353691 上传时间:2023-05-31 格式:DOCX 页数:13 大小:52.27KB
下载 相关 举报
Zend Freamwork配置源码.docx_第1页
第1页 / 共13页
Zend Freamwork配置源码.docx_第2页
第2页 / 共13页
Zend Freamwork配置源码.docx_第3页
第3页 / 共13页
Zend Freamwork配置源码.docx_第4页
第4页 / 共13页
Zend Freamwork配置源码.docx_第5页
第5页 / 共13页
Zend Freamwork配置源码.docx_第6页
第6页 / 共13页
Zend Freamwork配置源码.docx_第7页
第7页 / 共13页
Zend Freamwork配置源码.docx_第8页
第8页 / 共13页
Zend Freamwork配置源码.docx_第9页
第9页 / 共13页
Zend Freamwork配置源码.docx_第10页
第10页 / 共13页
Zend Freamwork配置源码.docx_第11页
第11页 / 共13页
Zend Freamwork配置源码.docx_第12页
第12页 / 共13页
Zend Freamwork配置源码.docx_第13页
第13页 / 共13页
亲,该文档总共13页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

Zend Freamwork配置源码.docx

《Zend Freamwork配置源码.docx》由会员分享,可在线阅读,更多相关《Zend Freamwork配置源码.docx(13页珍藏版)》请在冰点文库上搜索。

Zend Freamwork配置源码.docx

ZendFreamwork配置源码

配置目录

Zend框架就放在library中。

根目录.htaccess文件内容

RewriteEngineon

RewriteRule.*index.php

php_flagmagic_quotes_gpcoff

php_flagregister_globalsoff

application目录下.htaccess文件内容

denyfromall

index.php

php

date_default_timezone_set('Europe/London');

set_include_path('.'.PATH_SEPARATOR.'./library'.PATH_SEPARATOR.'./application/models/'.PATH_SEPARATOR.get_include_path());

include"Zend/Loader.php";

Zend_Loader:

:

loadClass('Zend_Controller_Front');

Zend_Loader:

:

loadClass('Zend_Db');

Zend_Loader:

:

loadClass('Zend_Db_Table');

Zend_Loader:

:

loadClass('Zend_Acl');

//设置数据库

$params=array('host'=>'127.0.0.1',

'username'=>'root',

'password'=>'root',

'dbname'=>'zend',

'charset'=>'utf8'

);

$db=Zend_Db:

:

factory('PDO_MYSQL',$params);

Zend_Db_Table:

:

setDefaultAdapter($db);

//设置控制器

$frontContraller=Zend_Controller_Front:

:

getInstance();

$frontContraller->throwExceptions(true);

$frontContraller->setControllerDirectory('./application/controllers');

//Acl

$acl=newZend_Acl();

$acl->addRole(newZend_Acl_Role('guest'));

$acl->addRole(newZend_Acl_Role('user'),'guest');

$acl->addRole(newZend_Acl_Role('admin'),'user');

$acl->add(newZend_Acl_Resource('index'));

$acl->add(newZend_Acl_Resource('work'));

$acl->add(newZend_Acl_Resource('admin'));

$acl->allow('guest','index');

$acl->allow('user','work');

$acl->allow('admin');

$privalege=$acl->isAllowed('guest','index')?

'allow':

'denied';

if($privalege=='denied')

exit('Denied');

//

$frontContraller->dispatch();

?

>

______________________________________________________

IndexController.php

php

classIndexControllerextendsZend_Controller_Action{

functioninit()

{

$this->initView();

$this->view->baseUrl=$this->_request->getBaseUrl();

Zend_Loader:

:

loadClass('Album');

}

functionindexAction()

{

$this->view->title='MyAlbums';

$album=newAlbum();

$this->view->albums=$album->fetchAll();

$this->render();

}

functionaddAction()

{

$this->view->title='AddNewAlbums';

if(strtolower($_SERVER['REQUEST_METHOD'])=='post')

{

Zend_Loader:

:

loadClass('Zend_Filter_StripTags');

$filter=newZend_Filter_StripTags();

$artist=$filter->filter($this->_request->getPost('artist'));

$artist=trim($artist);

$title=$filter->filter($this->_request->getPost('title'));

$title=trim($title);

if($artist!

=''&&$title!

='')

{

$data=array(

'artist'=>$artist,

'title'=>$title,

);

$album=newAlbum();

$album->insert($data);

$this->_redirect('./');

return;

}

}

$this->view->album=newstdClass();

$this->view->album->id=null;

$this->view->album->artist='';

$this->view->album->title='';

$this->view->action='add';

$this->view->buttonText='Add';

$this->render();

}

functioneditAction()

{

$this->view->title='EditnewAlbum';

$album=newAlbum();

if(strtolower($_SERVER['REQUEST_METHOD'])=='post')

{

Zend_Loader:

:

loadClass('Zend_Filter_StripTags');

$filter=newZend_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,

);

$where='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();

}

functiondeleteAction()

{

$this->view->title='DeleteNewAlbum';

$album=newAlbum();

if(strtolower($_SERVER['REQUEST_METHOD'])=='post')

{

Zend_Loader:

:

loadClass('Zend_Filter_Alpha');

$filter=newZend_Filter_Alpha();

$id=(int)$this->_request->getPost('id');

$del=$filter->filter($this->_request->getPost('del'));

if($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.phtml

phpinclude('header.phtml');?

>

phpecho$this->escape($this->title);?

>

phpecho$this->baseUrl;?

>/index/add">Addnewalbun

phpforeach($this->albumsAS$album):

?

>

phpendforeach;?

>

TitleArtist 

phpecho$this->escape($album->title);?

>

phpecho$this->escape($album->artist);?

>

phpecho$this->baseUrl;?

>/index/edit/id/

phpecho$album->id;?

>">Edit

phpecho$this->baseUrl;?

>/index/delete/id/

phpecho$album->id;?

>">Delete

phpinclude('footer.phtml');?

>

_______________________________________________________

header.phtml

DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http:

//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

//www.w3.org/1999/xhtml">

<?</p><p>phpecho$this->escape($this->title);?</p><p>>

____________________________________________________

footer.phtml

edit.phtml

phpinclude('header.phtml');?

>

phpecho$this->escape($this->title);?

>

phpinclude('_form.phtml');?

>

phpinclude('footer.phtml');?

>

delete.phtml

phpinclude('header.phtml');?

>

phpecho$this->escape($this->title);?

>

phpif($this->album):

?

>

phpecho$this->baseUrl?

>/index/delete"method="post">

Arreyousurethatyouwanttodelete

'

phpecho$this->escape($this->album->title);?

>'By'

phpecho$this->escape($this->album->artist);?

>'?

phpecho$this->escape($this->album->id);?

>"/>

phpelse:

?

>

Cannotfindalbum.

phpendif;?

>

phpinclude('footer.phtml');?

>

add.pthml

phpinclude('header.phtml');?

>

phpecho$this->escape($this->title);?

>

phpinclude('_form.phtml');?

>

phpinclude('footer.phtml');?

>

________________________________________________________form.phtml

phpecho$this->baseUrl;?

>/index/

phpecho$this->action;?

>"method="post">

Artist

phpecho$this->escape($this->album->artist);?

>"/>

Title

phpecho$this->escape($this->album->title);?

>"/>

phpecho$this->escape($this->album->id);?

>"/>

phpecho$this->escape($this->buttonText);?

>"/>

Album.php

php

classAlbumextendsZend_Db_Table

{

protected$_name='album';

}

?

>

MySQL

--phpMyAdminSQLDump

--version3.3.10

--

--

--主机:

localhost

--生成日期:

2011年09月29日03:

15

--服务器版本:

5.5.8

--PHP版本:

5.3.5

SETSQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--

--数据库:

`zend`

--

----------------------------------------------------------

--

--表的结构`album`

--

CREATETABLEIFNOTEXISTS`album`(

`id`int(10)unsignedNOTNULLAUTO_INCREMENT,

`artist`varchar(100)NOTNULL,

`title`varchar(100)NOTNULL,

PRIMARYKEY(`id`)

)ENGINE=InnoDBDEFAULTCHARSET=utf8AUTO_INCREMENT=6;

--

--转存表中的数据`album`

--

INSERTINTO`album`(`id`,`artist`,`title`)VALUES

(1,'kylin','你好13'),

(2,'yeleng','我想你'),

(5,'SZH','ILY');

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2