Jira issue originally created by user vrtak-cz:
Supports native DateTime in query parameters. (for more universal using)
* @var DateTime
$qb = $em->getRepository('Entities\Foo')->createQueryBuilder('f');
$qb->where("f.published <= ?1");
$qb->setParameter(1, new \DateTime('2012-12-21 23:59:59'));
Now display "Object of class DateTime could not be converted to string" error
Comment created by @beberlei:
This is another case for possible optimizations in my opinion, is it possible to access the parameter needles from the ResultSetMapping? If so then we should add a convertToParam method to each Doctrine\DBAL\Types\Type and allow conversions to take place or just do nothing. This woulld help with this issue, aswell as with other more complex types to be bound.
This affects the following loop inside Doctrine\ORM\Query:
According to Roman this should already be possible with:
$qb->setParameter(1, new \DateTime('2012-12-21 23:59:59'), \Doctrine\DBAL\Types\Type::DATETIME);
can you verify this?
Comment created by vrtak-cz:
No this featrue not work for me. (Same error message) I'm tested at latest BETA release & latest code from master branch (GitHub).
Fixed, QueryBuilder::setParameter() and QueryBuilder::setParameters() did not yet support setting parameter types.
Issue was closed with resolution "Fixed"