Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set group_concat_max_len on a PDO query

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

like image 789
user2668863 Avatar asked Aug 09 '13 18:08

user2668863


People also ask

What is set Group_concat_max_len?

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.)

What is Group_concat_max_len MySQL?

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 .

Is there a length limit to Group_concat?

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.


1 Answers

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

$conn->query("SET group_concat_max_len = 2048");
like image 200
castis Avatar answered Sep 19 '22 03:09

castis