고요빛물결

PHP Infinite Multi Level Comments

· 2017-10-28 (토) 07:17:32 · 1921

[code]

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`);

[/code]

 

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

댓글을 작성하시려면 로그인이 필요합니다.
+
분류 제목 글쓴이 날짜 조회
라라벨 17-11-11 조회 2,331
라라벨 17-11-10 조회 2,126
라라벨 17-11-07 조회 3,051
기타 17-10-31 조회 2,428
기타 17-10-30 조회 1,808
라라벨
[라라벨]
17-10-29 조회 1,924
기타 17-10-28 조회 2,317
기타 17-10-28 조회 1,922
라라벨 17-10-27 조회 3,613
기타 17-10-03 조회 3,164
기타 17-09-21 조회 2,230
라라벨 17-09-21 조회 2,446
라라벨 17-09-20 조회 2,494
라라벨 17-09-01 조회 2,440
라라벨
[라라벨]
17-06-30 조회 1,828
코드이그나이터 17-06-25 조회 2,922
코드이그나이터 17-06-23 조회 2,268
코드이그나이터 17-06-22 조회 2,883
라라벨 17-06-20 조회 3,325
일반 17-06-15 조회 1,983
일반 17-06-10 조회 2,410
기타 17-06-09 조회 2,755
라라벨 17-05-15 조회 1,820
라라벨 17-05-15 조회 1,846
라라벨 17-05-15 조회 1,930
기타 17-05-10 조회 1,966
기타 17-04-11 조회 2,122
라라벨 17-04-11 조회 2,576
라라벨 17-04-11 조회 1,867
기타 17-04-10 조회 2,167