当我使用PHP爆炸功能时,在用逗号分隔字段时,当实际字段中有逗号时,它会导致我出现问题,如果我正确使用控制字符,你们中的任何人都可以告诉我吗?
0x1d =组分隔符
0x1f =单位/字段分隔符
0x1e =记录分隔符
SELECT
sub.merchant_id,
SUM(sub.rating_count) as total_count,
ROUND(sub.rating_total / SUM(sub.rating_count)) as rating,
GROUP_CONCAT(sub.provider_info,0x1f,sub.rating_count,0x1f,sub.average_rating SEPARATOR 0x1d) as provider_counts
FROM(
SELECT merchants.merchant_id as merchant_id,
CONCAT(review_providers.name,0x1e,review_types.profile_url) as provider_info,
review_providers.id as provider_id,
ROUND(AVG(reviews.rating),1) as average_rating,
SUM(reviews.rating) as rating_total,
COUNT(reviews.rating) as rating_count
FROM merchants
INNER JOIN review_types ON merchants.merchant_id = review_types.foreign_key AND review_types.type = "merchants"
INNER JOIN reviews ON review_types.id = reviews.review_type_id
INNER JOIN review_providers ON review_types.review_provider_id = review_providers.id
WHERE merchants.merchant_id IN(1,2,3)
GROUP BY merchants.merchant_id, review_providers.id
) as sub
GROUP BY sub.merchant_id
然后我可以使用explode(chr(29),$ row ['provider_counts'])来正确分离组。