In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "how to reply multiple times by php". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Php to achieve multiple reply method: 1, create "function commentList ($aid,$pid = 0 recently received resultreply array ()) {...}"; 2, through the "$this- > commentList ($aid);" method can be called.
This article operating environment: Windows7 system, PHP7.4 version, Dell G3 computer.
How does php reply multiple times?
Implementation of unlimited level comment reply function in PHP
Protected function commentList ($aid,$pid) {$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;}
Call method
$this- > commentList ($aid)
Use tp5 to write articles, comment and reply in the project.
The id table that uses pid to identify the reply table in the table has the following structure
CREATE TABLE `comment` (`id`int (11) unsigned NOT NULL AUTO_INCREMENT, `author_ id` int (11) unsigned NOT NULL DEFAULT'0' COMMENT 'author ID', `article_ id`int (11) unsigned NOT NULL DEFAULT' 0' COMMENT 'article ID', `pid`int (11) unsigned NOT NULL DEFAULT' 0comment, `uid`int (11) unsigned NOT NULL DEFAULT'0' COMMENT 'commentator ID', `comment`varchar (250) NOT NULL DEFAULT', `give_ count`int (10) unsigned NOT NULL DEFAULT'0' COMMENT 'number of likes `add_ time` int (10) unsigned NOT NULL DEFAULT '0immediate primary KEY (`id`), KEY `author_ id` (`pid`), KEY `pid` (`pid`) ENGINE=MyISAM AUTO_INCREMENT=97 DEFAULT CHARSET=utf8 COMMENT=' article comment table' "how to achieve multiple replies by php" ends here. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.