1

I am working on the Messaging system. Using query builder, I wanna get a message list link to the specific user. There are From and To in the database, and To will be the specific user, and From will be any user link to that specific user.

$messages = $MessageRepository->createQueryBuilder('im')
                                  ->groupBy('im.from')
                                  ->where('im.to = :userId')
                                  ->setParameter('userId', $user->getId())
                                  ->setMaxResults(30)
                                  ->getQuery()->getResult();
return $messages;

But I get this error.

SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'db_message.i0_.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

How to fix this? Thank you.

1

0

Browse other questions tagged or ask your own question.