Home » Php » php – Set group_concat_max_len on a PDO query

php – Set group_concat_max_len on a PDO query

Posted by: admin July 12, 2020 Leave a comment

Questions:

I have the following query:

$cases = $conn->prepare("SELECT GROUP_CONCAT(text SEPARATOR '|') as texts, year FROM cases GROUP BY year ORDER BY ano DESC");
$cases->execute();
$cases_result = $cases->fetchAll(PDO::FETCH_OBJ);

But some texts are not showing completely

So I have to change the value of group_concat_max_len. I did as follows:

mysql_query("SET group_concat_max_len = 2048");

But using PDO not know how

How to&Answers:

Can you not use $conn->query()?

$conn->query("SET group_concat_max_len = 2048");