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
The group_concat_max_len variable sets the result length in bytes for the GROUP_CONCAT() function to accommodate a potentially long string. (The default group_concat_max_len setting is 1024 bytes.)
As MySQL Blog by @Shlomi Noach Here group_concat_max_len : This parameter limits the maximum text length of a GROUP_CONCAT concatenation result. It defaults to 1024 .
I'm using GROUP_CONCAT() in a MySQL query to convert multiple rows into a single string. However, the maximum length of the result of this function is 1024 characters.
Can you not use $conn->query()
?
$conn->query("SET group_concat_max_len = 2048");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With