国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

??
Zend Framework實(shí)現(xiàn)具有基本功能的留言本(附demo源碼下載),zenddemo
您可能感興趣的文章:
? ??? ?? PHP ???? Zend Framework實(shí)現(xiàn)具有基本功能的留言本(附demo源碼下載),zenddemo_PHP教程

Zend Framework實(shí)現(xiàn)具有基本功能的留言本(附demo源碼下載),zenddemo_PHP教程

Jul 12, 2016 am 08:56 AM
framework htaccess zend

Zend Framework實(shí)現(xiàn)具有基本功能的留言本(附demo源碼下載),zenddemo

本文實(shí)例講述了Zend Framework實(shí)現(xiàn)具有基本功能的留言本。分享給大家供大家參考,具體如下:

一個留言本...具有的基本功能就是.1.發(fā)表留言. 2.回復(fù)留言.3.管理留言(修改,刪除等操作).

我這里只是寫了基本的操作,比如加留言驗(yàn)證碼.頁面的美化什么的我都
沒有做.我只是給大家一個思想..很多東西要靠我們自己去學(xué)了.

另一個就是我的留言用了AJAX.就是你一發(fā)表.數(shù)據(jù)就會在頁面顯示..不過大家要了解Jquery的AJAX的用法..我相信大部分人都會這個JS類庫吧.

要是不懂也沒關(guān)系..你們可以改成不是AJAX的..只要把發(fā)表留言的FROM的提交動作轉(zhuǎn)換成我們控制里的一個動作..相信這個不是問題.好了..開始工作:

我們的目錄結(jié)構(gòu)和以前一樣,大致不變..下面要有改動的..大家也不要急..我會教大家如何做:

第一:先建立好我們的模板頁面(View)..

按照上篇教程的目錄.application/views/scripts目錄下有一些模板頁.如(index.phtml,edit.phtml).我們刪除它們..現(xiàn)在加一個message文件夾.

在message里加上(edit.phtml,index.phtml,message.phtml)三個模板文件.完成后.我們在application/views/scripts/目錄下加上(header.phtml,footer.phtml)二個模板文件.

因?yàn)檫@二個文件以后會重用來..所以把他們直接放到application/views/scripts/下..好了模板建立好了.現(xiàn)在就是加入一個HTML.JS.IMAGE了.我把他們這些都放在網(wǎng)站根目錄public文件夾下.大家可以對應(yīng)我的源碼來看一下..要是有點(diǎn)亂..請大家根據(jù)源碼來看這教程..(^_^不好意思,我只能這樣表達(dá).我也不知道如何寫才能讓你們更了解.請大家體諒啊!)

第二:接下來,我們寫我們的數(shù)據(jù)層程序(Model).

1.我們在原來的表中加上下面幾個字段:pid(標(biāo)志是否是回復(fù),0為留言.為為0的是為回復(fù)) ,author(留言者),headimg(留言者頭像),email(留言者電子郵件), ip(留言者IP地址),
show(留言是否顯示.這個要在生臺管理能用.這教程這里沒有用到.), addtime(留言時間), updatetime(留言修改時間).字段類型的設(shè)置請大家看源碼SQL文件.

2.我們在application/models/目錄下有一個Message.php.我們先寫好我們留言本的Model .主要是對留言本數(shù)據(jù)層的操作.我增加了下面幾個方法:
getAllMessage(取到所有的留言) , getAllReMessage(取到所有的回復(fù)留言數(shù)據(jù)) , getMessageByID(根據(jù)ID取留言數(shù)據(jù)), updateMessageByID(修改留言), delMessageByID(刪除留言)

具體程序如下(程序上面也有注解):

class Message extends Zend_Db_Table
{
 protected $_name ="message";
 protected $_primary = 'id';
 /* * 取到所有的留言 */
 public function getAllMessage(){
 $messageArray=$this->fetchAll("message.pid=0",
      "message.id DESC")->toArray();
 return $messageArray;
 }
 /* * 取到所有的回復(fù)留言數(shù)據(jù) */
 public function getAllReMessage(){
 $ReArray=$this->fetchAll("message.pid!=0",
      "message.id DESC")->toArray();
 return $ReArray;
 }
 /* * 根據(jù)ID取留言數(shù)據(jù) */
 public function getMessageByID($id){
 $messageone=$this->fetchAll('id='.$id)->toArray();
 return $messageone;
 }
 /* * 修改留言 */
 public function updateMessageByID($array,$id){
 $db = $this->getAdapter();
 $where=$db->quoteInto('id = ?', $id);
 $this->update($array, $where);
 }
 /* * 刪除留言 */
 public function delMessageByID($id){
 $where = 'id = ' . $id;
   $this->delete($where);
   return true;
 }
}

第三:完成上面二項(xiàng).最后就我們的控制層了(Controller).打開application/controllers/IndexController.php這個控制器..把原來的不要的東西給刪除了.我在上面加上了下面

一個message方法(也叫動作Action).不過其它的Action都有改動..請大家參與源碼來進(jìn)行分析.這里我只貼也我新加入的messageAction這個方法(代碼上都有注解.請自行查看.謝謝):

public function messageAction()
{
 if($this->_request->isPost()){
 Zend_Loader::loadClass('Zend_Filter_StripTags');
 $filter=new Zend_Filter_StripTags();
 $username=$filter->filter($this->_request->getPost('username'));
 $email=$filter->filter($this->_request->getPost('email'));
 $content=$filter->filter($this->_request->getPost('content'));
 $title=$filter->filter($this->_request->getPost('title'));
 $messageid=$filter->filter($this->_request->getPost('messageid'));
 $headimg=$filter->filter($this->_request->getPost('headimg'));
 $message=new Message();
 $db=$message->getAdapter();
 if($username!=''&&$email!=''&&$messageid!=''&&$content!=''){
 require_once 'Zend/Validate/EmailAddress.php';
 $validator = new Zend_Validate_EmailAddress();
 if ($validator->isValid($email)) {
 //取IP地址..這里只是簡單取IP
 $IP=$_SERVER ["REMOTE_ADDR"];
 $data=array(
 'title'=>$title,
 'author'=>$username,
  'pid'=>$messageid,
 'headimg'=>$headimg,
 'email'=>$email,
 'show'=>'1',
 'content'=>$content,
  'ip'=>$IP,
 'addtime'=>time(),
 'updatetime'=>time()
 );
 $message->insert($data);
 $db->lastInsertId();
 unset($data);
  //取到所有留言getAllMessage,getAllReMessage
  //二個方法在Model(Message.php)里定義的
  $this->view->messages=$message->getAllMessage();
 //取到所有回復(fù)數(shù)據(jù)
 $this->view->arrReviews=$message->getAllReMessage();
 $this->view->flag='0';
 $this->view->message='您的留言發(fā)表成功!';
 echo $this->view->render('message/message.phtml');
 } else {
 $this->view->flag='5';
 $this->view->message='對不起!您填寫有電子郵箱地址有誤!';
 echo $this->view->render('message/message.phtml');
 }
  }elseif($username==''){
  $this->view->flag='1';
 $this->view->message='對不起!您的大名不能為空!';
  echo $this->view->render('message/message.phtml');
 }elseif($messageid==''){
  $this->view->flag='2';
 $this->view->message='對不起!回復(fù)留言編號不能為空!';
  echo $this->view->render('message/message.phtml');
 }elseif($content==''){
  $this->view->flag='3';
 $this->view->message='對不起!您填寫的留言內(nèi)容不能為空!';
  echo $this->view->render('message/message.phtml');
  }
  }else{
  echo $this->view->render('message/index.phtml');
  }
}

只是沒有驗(yàn)證碼以及分頁功能..后面一篇會有教程進(jìn)一步講解.

總結(jié):到這里就完成了一個留言本的編寫.當(dāng)然很簡單的功能..還是那句話.我只是把我會的寫給大家..只是一個思想..我也只會這些..所以寫的好與不好..請大家自己進(jìn)行權(quán)衡

完整實(shí)例代碼點(diǎn)擊此處本站下載。

更多關(guān)于zend相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Zend FrameWork框架入門教程》、《php優(yōu)秀開發(fā)框架總結(jié)》、《Yii框架入門及常用技巧總結(jié)》、《ThinkPHP入門教程》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總》

希望本文所述對大家基于Zend Framework框架的PHP程序設(shè)計(jì)有所幫助。

您可能感興趣的文章:

  • Zend Framework框架教程之Zend_Db_Table_Rowset用法實(shí)例分析
  • Zend Framework教程之Zend_Db_Table_Row用法實(shí)例分析
  • Zend Framework教程之Zend_Db_Table用法詳解
  • Zend Framework教程之Zend_Form組件實(shí)現(xiàn)表單提交并顯示錯誤提示的方法
  • Zend Framework開發(fā)入門經(jīng)典教程
  • Zend Framework框架Smarty擴(kuò)展實(shí)現(xiàn)方法
  • Zend Framework框架路由機(jī)制代碼分析
  • Zend Framework實(shí)現(xiàn)將session存儲在memcache中的方法
  • Zend Framework分頁類用法詳解
  • Zend Framework實(shí)現(xiàn)多文件上傳功能實(shí)例
  • Zend Framework入門之環(huán)境配置及第一個Hello World示例(附demo源碼下載)
  • Zend Framework教程之連接數(shù)據(jù)庫并執(zhí)行增刪查的方法(附demo源碼下載)
  • Zend Framework教程之Zend_Db_Table表關(guān)聯(lián)實(shí)例詳解

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1113722.htmlTechArticleZend Framework實(shí)現(xiàn)具有基本功能的留言本(附demo源碼下載),zenddemo 本文實(shí)例講述了Zend Framework實(shí)現(xiàn)具有基本功能的留言本。分享給大家供大家參...
? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

??? ????
1601
29
PHP ????
1502
276
???
Windows 11/10?? SetupDiag? ???? Windows ????? ??? ???? ?? Windows 11/10?? SetupDiag? ???? Windows ????? ??? ???? ?? Apr 17, 2023 am 10:07 AM

Windows 11 ?? Windows 10 PC? ????? ?? ???? ??? ?? ??? ????? ??? ?? ??? ???? ?? ??? ?????. ??? ?? ??? ???? ?? ?????? ????? ???? ??? ??? ? ????. ??? ?? ??? ???? ??? ??? ??? ??? ? ? ???? ??? ??? ? ????. ??? ?? ??? ???? ?? ??? ??? ???? ????? ?????. ??? ??? ??? ?? ? ?? ??? ????. ? ?? ??? ?? ??? ?? ???? ? ??? ?? Microsoft?? ???? SetupDiag?? ?? ??? ??? ? ? ????.

Microsoft NET Framework ?? ?? ?? ?? 0x800c0006 ?? Microsoft NET Framework ?? ?? ?? ?? 0x800c0006 ?? May 05, 2023 pm 04:01 PM

.NET Framework 4? ???? ?? ???? Windows?? ?? ??? ??????? ???? ? ?????. ??? .NET Framework 4? ?????? ???? ?? ?? ???? ?? ????? ??? ???? "?? ?? 0x800c0006?? ?? ????? ???? ??? .NET Framework 4? ???? ?????"?? ?? ???? ????? ??????. ??? .NETFramework4? ???? ???? ? ??? ????? ??? ??? ?? ????.

SCNotification? ??? ?????. [??? ?? 5??] SCNotification? ??? ?????. [??? ?? 5??] May 17, 2023 pm 09:35 PM

Windows ???? ???? ??? ??? SCNotification? ??? ??????. ??? ??? ? ????. SCNotification.exe? ?? ?? ? ???? ??? ?? PC? ??? ??? ??? ???? Microsoft ??? ?? ?????. ? ??? ??? ?? ??? ????? ??? ????. ??? ?? SCNotification? ??? ??? ??? ???? ?? ?? clr20r3?? ??? ? ????. ? ????? SCNotification? ??? ???? ?? ??? ?? ??? ???? ?? ??? ? ?? ??? ???????. SCNotification.e? ?????

PHP ?? ?????: Zend ????? ?? ???? PHP ?? ?????: Zend ????? ?? ???? Jun 19, 2023 am 08:09 AM

PHP ?? ?????: ZendFramework ?? ???? ZendFramework? PHP?? ???? ?? ZendTechnologies?? ?? ???? ?? ?? ? ??? ????????. ZendFramework? MVC ??? ??? ???? Web2.0 ?????? ? Web Serve ??? ???? ?? ??? ??? ?? ????? ???? ?????. ZendFramework? PHP ?????? ?? ?? ?? ???? ??? ??? ??? ??? ????.

Microsoft .NET Framework 4.5.2, 4.6 ? 4.6.1? 2022? 4?? ??? ?????. Microsoft .NET Framework 4.5.2, 4.6 ? 4.6.1? 2022? 4?? ??? ?????. Apr 17, 2023 pm 02:25 PM

Microsoft.NET ?? 4.5.2, 4.6 ?? 4.6.1? ??? Microsoft Windows ???? Microsoft?? ?? ?? ????? ?? ?????? ????? ??? ?? ??? Microsoft Framework? ???? ???. Microsoft? ??? ? ?? ????? ?? 2022? 4? 26?? ??? ?????. ?? ??? ???? ?? ??? "?? ?? ?? ?? ??"? ?? ? ????. ???? ??? ??? Windows ????? ?? ?? ??? ?????. ??? ???? .NET Framework 4.8? ?? ?? ??? ?????? ?? ???? ????. ???? ?????? ?? ???

Zend Framework?? ?? ??? ?? ACL(Access Control List)? ???? ?? Zend Framework?? ?? ??? ?? ACL(Access Control List)? ???? ?? Jul 29, 2023 am 09:24 AM

Zend Framework?? ?? ??? ?? ACL(AccessControlList)? ???? ?? ??: ? ???????? ?? ??? ??? ?????. ?? ???? ??? ??? ?? ???? ???? ???? ? ??? ?? ?? ???? ?????. Zend ?????? ACL(AccessControlList) ?? ??? ???? ?? ??? ???? ??? ??? ?????. ? ????? Zend Framework?? ACL? ???? ??? ?????.

Windows 11? KB5012643?? ?? .NET Framework 3.5 ?? ??? Windows 11? KB5012643?? ?? .NET Framework 3.5 ?? ??? May 09, 2023 pm 01:07 PM

Windows 11? KB5012643? ??? ????? ??? ??? ??? ?? ?? ??? ?? ???? ? ???? ?????. ? ??? ??? Microsoft? ???? ??? ??? ?? ??? ???? ?? ??? ??? ????. ??, ??? ? ?? ??? ? ??? ???? ? Microsoft? ? ?? ????? ??? ????? ? ?? ??? ???????. Windows 11 ?? 22000.652? ?? ? ?? ?? ?? ??? ?? ??? Windows 11 ????? ?? .NET Framework 3.5 ?? ????? ???? ???? ? ??? ??? ? ??? ?????. ??? ? ???? ??? ??? ???.

Windows 11?? 0xc0000135 ??? ???? ??(KB5013943 ???? ?? ??) Windows 11?? 0xc0000135 ??? ???? ??(KB5013943 ???? ?? ??) May 11, 2023 am 08:28 AM

0xc0000135 ??? ???? ? ?????? ?? Microsoft ??? ??? 0xc0000135 ?? ??? .NetFramework ??? ??? ????. .NetFramework3.5? ???? ?? ?? ?? ????? ?? Windows 11 ?????? ???? ?? ? ????. ??? 0xc0000135 ?? ??? ???? PC?? .NetFramework3.5? ????? ? ??? ??? ? ????. ???? ?? ??????? .NetFramework.dll ??? ???? ??????? ???? ?????. ???

See all articles