PHP Infinite Multi Level Comments > PHP프레임워크

PHP프레임워크

PHP Infinite Multi Level Comments 정보

기타 PHP Infinite Multi Level Comments

본문


CREATE TABLE IF NOT EXISTS `comment` (
    `cid` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
    `sid` smallint(5) unsigned NOT NULL,
    `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `message` varchar(255) NOT NULL,
    `parent` smallint(5) unsigned DEFAULT NULL,
    `children` tinyint(1) unsigned NOT NULL DEFAULT '0',
    `author_name` varchar(40) NOT NULL,
    `author_email` varchar(255) NOT NULL,
    PRIMARY KEY (`cid`),
    KEY `parent` (`parent`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
--
-- Constraints for dumped tables
--
-- Constraints for table `comment`
--
ALTER TABLE `comment`
    ADD CONSTRAINT `comment_ibfk_2` FOREIGN KEY (`parent`) REFERENCES `comment` (`cid`);

 

parent, child를 넣어서 무한 커멘트를 만들 수 있는 것 같습니다.

 

링크2의 데모를 보면 무한 Reply로....

 

대략적인 구현은 스택오버플로우에서 참조로..

https://stackoverflow.com/questions/35884548/laravel-query-or-function-for-nested-infinite-sub-category

 

이 방식을 이용하면 무한 카테고리도 가능하겠네요..

 

morph는 Post(또는 Article)이나 다른 Product등에 커멘트를 달수 있게 해주는 것 같습니다.

 

multi-level은 parent_id와 child_id로 해서 만들어 지는 것 같습니다.

 

https://stackoverflow.com/questions/35073613/multi-tiered-comment-system-laravel/35074401

추천
1

댓글 0개

전체 289 |RSS
PHP프레임워크 내용 검색

회원로그인

진행중 포인트경매

  1. 참여79 회 시작24.04.19 15:40 종료24.04.26 15:40
(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT