[DBAL-544] Where's the Query::HYDRATE_BOTH constant? Created: 12/Jun/13  Updated: 22/Dec/13  Resolved: 22/Dec/13

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.3.4
Fix Version/s: 2.5

Type: Bug Priority: Minor
Reporter: Julio Montoya Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: Query::HYDRATE_BOTH

Doctrine 2.3.4 DBAL + ORM, using Silex


In the documentation of the the ResultStatement::fetch() function says that we should use the Query::HYDRATE_* constants but that constant does not exist at least not in 2.3.4.

Should I just use PDO::FETCH_BOTH? But if I change the driver to sqlite or whatever is it going to work well?

Comment by Marco Pivetta [ 12/Jun/13 ]

Query constants are defined in AbstractQuery (superclass of the Query class) - see https://github.com/doctrine/doctrine2/blob/2.3.4/lib/Doctrine/ORM/AbstractQuery.php#L45-L60

Comment by Julio Montoya [ 12/Jun/13 ]

Hello Marco! Thanks for your fast answer!
Some comments: The constant HYDRATE_BOTH doesn't exist, at least not with that name. Documentation should be updated too.
Another thing I'm obliged to use ORM to call a constant in DBAL? Not a problem for me because I need both

Comment by Marco Pivetta [ 12/Jun/13 ]

Sorry, confused this one as an ORM issue.

Comment by Marco Pivetta [ 12/Jun/13 ]

Checked briefly - you should indeed use the `PDO::FETCH_*` constants.

Can you link the document that contains the imprecision?

Comment by Julio Montoya [ 12/Jun/13 ]

This is the documentation in the fetch(), fetchAll() functions in DBAL:


For example, if I want to fetch an Object what should I use 1. or 2. ? I don't know if this have some implications in other drivers.

1. $statement->fetch(\Doctrine\ORM\Query::HYDRATE_OBJECT);
2. $statement->fetch(PDO::FETCH_OBJ);

An update to the documentation will be fine too:


it should be:


instead of


with a list of options (constants) ...

Comment by Julio Montoya [ 13/Jun/13 ]

Working in a PR but first we need to define those constants ...


Comment by Steve Müller [ 28/Nov/13 ]

I guess this is a Doctrine 1 legacy problem. I was confused by the methods' documentation today, too. I think the documentation was copied from Doctrine 1 code and never updated. You should definitely use PDO_FETCH* constants for this as the drivers rely on this. I will PR a documentation update these days...

Comment by Steve Müller [ 22/Dec/13 ]

Documentation fixed in commit: https://github.com/doctrine/dbal/commit/7fc6b420a296504c56859f67ed1dc16a9a3bbdfe

Generated at Sun Aug 30 22:54:46 EDT 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.