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

php如何實(shí)現(xiàn)多次回復(fù)

本篇內(nèi)容介紹了“php如何實(shí)現(xiàn)多次回復(fù)”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

創(chuàng)新互聯(lián)公司擁有一支富有激情的企業(yè)網(wǎng)站制作團(tuán)隊(duì),在互聯(lián)網(wǎng)網(wǎng)站建設(shè)行業(yè)深耕十多年,專業(yè)且經(jīng)驗(yàn)豐富。十多年網(wǎng)站優(yōu)化營(yíng)銷經(jīng)驗(yàn),我們已為超過(guò)千家中小企業(yè)提供了成都網(wǎng)站建設(shè)、網(wǎng)站制作解決方案,按需網(wǎng)站建設(shè),設(shè)計(jì)滿意,售后服務(wù)無(wú)憂。所有客戶皆提供一年免費(fèi)網(wǎng)站維護(hù)!

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

php如何實(shí)現(xiàn)多次回復(fù)

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

php怎么實(shí)現(xiàn)多次回復(fù)?

PHP無(wú)限級(jí)評(píng)論回復(fù)功能實(shí)現(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;
}

調(diào)用方法

$this->commentList($aid);

項(xiàng)目中使用tp5寫文章評(píng)論回復(fù)功能

表中使用pid來(lái)標(biāo)識(shí)回復(fù)表的id 表結(jié)構(gòu)如下

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 '評(píng)論人ID',
`comment` varchar(250) NOT NULL DEFAULT '',
`give_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '評(píng)論點(diǎn)贊數(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='文章評(píng)論表'

“php如何實(shí)現(xiàn)多次回復(fù)”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!

分享文章:php如何實(shí)現(xiàn)多次回復(fù)
本文地址:http://www.chinadenli.net/article6/pecgog.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊(cè)靜態(tài)網(wǎng)站網(wǎng)站改版營(yíng)銷型網(wǎng)站建設(shè)標(biāo)簽優(yōu)化手機(jī)網(wǎng)站建設(shè)

廣告

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

營(yíng)銷型網(wǎng)站建設(shè)