We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jira issue originally created by user max.summe:
QueryBuilder->set method uses Expr\Comparison object, which tries to cast values as strings.
When trying to set('updated', new \DateTime) in an update statement, this causes an exception as \DateTime has no **toString method.
Not sure what the fix is - the format for the \DateTime there depends on the platform and ( I think) the type of field.
The text was updated successfully, but these errors were encountered:
Comment created by stof:
you should not set a value directly in the DQL query. You should use the query parameters instead.
Sorry, something went wrong.
Comment created by max.summe:
So you're saying it should not be used like this.
$qb = $em->createQueryBuilder(); $qb->update('User', 'u') ->set("u.field", "new value") ->where("u.field = :oldvalue") ->setParameter("oldvalue", "old value");
Instead, it should be:
$qb = $em->createQueryBuilder(); $qb->update('User', 'u') ->set("u.field", ":value") ->where("u.field = :oldvalue") ->setParameter("oldvalue", "old value") ->setParameter("value", "new value");
Is that correct?
If yes, it would be helpful to add an example to the documentation in this page: http://docs.doctrine-project.org/en/latest/reference/query-builder.html
beberlei
No branches or pull requests
Jira issue originally created by user max.summe:
QueryBuilder->set method uses Expr\Comparison object, which tries to cast values as strings.
When trying to set('updated', new \DateTime) in an update statement, this causes an exception as \DateTime has no **toString method.
Not sure what the fix is - the format for the \DateTime there depends on the platform and ( I think) the type of field.
The text was updated successfully, but these errors were encountered: