$model = Item::find()
->select('group_concat(item.ID) AS ItemID')
->joinWith('image', true, 'LEFT JOIN')
->where('item.user_id = :id', [':id' => Yii::$app->user->identity->ID])
->all();
You see, if I do like this it will print me the string of itemID with 145 elements separated by comma, but if there are 3000k records in db, so it will output me only half of them.
The question is, is it possible to set session group_concat_max_len in Yii2 framework?
You can access your application's database connection object using
Yii::$app->db
. You can then set your mysql variable just before the call tofind
:For consistency, you can set your
group_concat_max_len
as a Yii parameter in your config file to make it accessible application-wide.You can then call the query above using