欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

php怎么實現(xiàn)多次回復

php實現(xiàn)多次回復的方法:1、創(chuàng)建“function commentList($aid,$pid = 0,&$result=array()){...}”;2、通過“$this->commentList($aid);”方式調用即可。

讓客戶滿意是我們工作的目標,不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領域值得信任、有價值的長期合作伙伴,公司提供的服務項目有:域名與空間、虛擬主機、營銷軟件、網(wǎng)站建設、吉首網(wǎng)站維護、網(wǎng)站推廣。

本文操作環(huán)境:Windows7系統(tǒng),PHP7.4版,Dell G3電腦。

php怎么實現(xiàn)多次回復?

PHP無限級評論回復功能實現(xiàn)

protected function commentList($aid,$pid = 0,&$result=array()){ $arr = ArticleComment::relation(['usertalent'=> function($query){ $query->field('id,talent_usernickname,talent_avatar'); }])->where(['pid' => $pid])->where(['article_id' => $aid])->order('id desc')->select(); if(empty($arr)){ return array(); } foreach ($arr as $cm) { $thisArr=&$result[]; $cm["children"] = $this->commentList($aid,$cm["id"],$thisArr); $thisArr = $cm; } return $result;}

調用方法

$this->commentList($aid);

項目中使用tp5寫文章評論回復功能

表中使用pid來標識回復表的id 表結構如下

CREATE TABLE `bcpub_article_comment` (`id` int(11) unsigned NOT NULL AUTO_INCREMENT,`author_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '作者ID',`article_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '文章ID',`pid` int(11) unsigned NOT NULL DEFAULT '0',`uid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '評論人ID',`comment` varchar(250) NOT NULL DEFAULT '',`give_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '評論點贊數(shù)量',`add_time` int(10) unsigned NOT NULL DEFAULT '0',PRIMARY KEY (`id`),KEY `author_id` (`author_id`),KEY `pid` (`pid`)) ENGINE=MyISAM AUTO_INCREMENT=97 DEFAULT CHARSET=utf8 COMMENT='文章評論表'

推薦學習:《PHP視頻教程》

當前文章:php怎么實現(xiàn)多次回復
標題路徑:http://chinadenli.net/article8/cgsdip.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供用戶體驗響應式網(wǎng)站自適應網(wǎng)站小程序開發(fā)品牌網(wǎng)站建設網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

外貿網(wǎng)站制作