Symfony3 convert postgres column timestamp(6) without timezone to valid type

Viewed 652

I try to build an application with symfony 3.3.1 using a Postgres 9.2 database. The database schema already exists and can't be changed.

In the following example I'm trying to fetch a Stud object from the database, it is connected with some other tables by foreign keys. Some columns have the type "timestamp(6) without timezone".

class StudentController extends Controller
{
    /**
     * @Route("/student")
     */
    public function indexAction()
    {
        $studRepository = $this->getDoctrine()->getRepository(Stud::class);
        $student = $studRepository->findOneBy(['sid' => 123456]);
        var_dump($student);
    }
}

I get the following error message: "Could not convert database value "2017-05-26 12:21:30.565211+02" to Doctrine Type datetimetz. Expected format: Y-m-d H:i:sO"

I tried to add something like this to the config.yml without success.

doctrine:
  dbal:
    mapping_types:
      datetimetz: datetime

I also found a hint on this site 18. Known Vendor Issues, but I don't know how to use something like

Type::overrideType('datetimetz', 'Doctrine\DBAL\Types\VarDateTimeType');

properly. I hope somebody has a tip for me, thanks!

0 Answers
Related