3

I am using group_concat() in my Laravel 5 model's Query. In this regard I use this statement.

DB::statement('SET GLOBAL group_concat_max_len = 1000000');

It is working fine in Locally but it not working in Live online server.

Could anyone say where is the problem ??

abu abu
  • 6,599
  • 19
  • 74
  • 131

1 Answers1

4

A few further questions/answers may help us help you:

  • Does your hosting provider enable modification of global variables?
  • Does your user permissions have the "SET" privilege?
  • Is the query throwing an error of any kind in your non-local environment?

A better check would be to see if the transaction has processed successfully using a sub-sequent check request on the database, because if you have set it globally it should work for all sessions, even ones not executed by your code.

SHOW VARIABLES LIKE 'group%';

Should indicate the current group concat max length configured.

Goodluck.

Dan Belden
  • 1,199
  • 1
  • 9
  • 20
  • 1
    Thanks Dan Belden for your valuable comment. This one is working DB::statement('SET SESSION group_concat_max_len = 1000000'); – abu abu Jun 27 '15 at 07:28
  • In which case if it still isn't working "1000000" may still be too small for your data? A good indicator is if the group_concat column is truncated... – Dan Belden Jun 27 '15 at 07:41
  • Thanks Dan Belden for your valuable comment. I looked for better alternative of group_concat for a long time. But I failed to gather a better alternative of group_concat . Could you please help me in this regard ?? – abu abu Jun 27 '15 at 08:07
  • I encountered this problem in a recent project, the simplest solution is to dynamically calculate and set, the group concat value ahead of the SELECT so that no truncation can happen. But this has memory impact for the server. It's difficult to provide any more support without seeing the query in which you are trying to use the GROUP_CONCAT() method. In which case, I'd suggest opening another question with that query and ask how to compute the group_concat value and someone may be able to help you in the SQL channel. Best of luck, MySQL is a tricky beast. – Dan Belden Jun 27 '15 at 08:12
  • Thanks Dan Belden for your valuable comment. I tried a lot through stackoverflow,but either people don,t reply to the question or they failed to understand or they suggest me to use GROUP_CONCAT() . Even stackoverflow block me ask quetion. Actually I would like to fetch date wise result from a table, where I tried to pick result as bunch with related **Date**. Could you please help me in this regard ?? – abu abu Jun 27 '15 at 08:32
  • here is the question http://stackoverflow.com/questions/31086926/how-to-get-bunched-result. Thanks – abu abu Jun 27 '15 at 08:53