需要在MySQL数据库中配置
group_concat_max_len = 4294967295
函数如下:
CREATE DEFINER=`root`@`%` FUNCTION `queryChilds`(`uid` varchar(32)) RETURNS longtext CHARSET utf8 BEGIN DECLARE sTemp LONGTEXT; DECLARE sTempChd LONGTEXT; SET sTemp = ''; SET sTempChd = uid; WHILE sTempChd is not NULL DO SET sTemp = CONCAT(sTemp,',',sTempChd); SELECT group_concat(id) INTO sTempChd FROM t_user where FIND_IN_SET(referrer,sTempChd)>0; END WHILE; return sTemp; END