Why does select max from a column with querybuilder return an array?

I’m trying to get the last contact of a user, here is the query:

public function dateDernierContact($utilisateur): ?Contact
    {
        return $this->createQueryBuilder('c')
            ->select('MAX(c.dateFin)')
            ->andWhere('c.utilisateur = :val')
            ->andWhere('c.archive = true')
            ->setParameter('val', $utilisateur)
            ->getQuery()
            ->getOneOrNullResult()
        ;
    }

And where I use it:

$dateDeb=strtotime($contactRepository->dateDernierContact($user->getId()));

Last, the error:

Warning: strtotime() expects parameter 1 to be string, array given

Also I use Mariadb from wamp don’t know if it could be the problem.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *