DBAL-544: Where's the Query::HYDRATE_BOTH constant? #1750

Closed
doctrinebot opened this Issue Jun 12, 2013 · 9 comments

2 participants

@doctrinebot

Jira issue originally created by user jmontoya:

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?

@doctrinebot

Comment created by @ocramius:

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

@doctrinebot

Comment created by jmontoya:

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 :)

@doctrinebot

Comment created by @ocramius:

Sorry, confused this one as an ORM issue.

@doctrinebot

Comment created by @ocramius:

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

Can you link the document that contains the imprecision?

@doctrinebot

Comment created by jmontoya:

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

https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Driver/ResultStatement.php#L61

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:

http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/data-retrieval-and-manipulation.html#using-prepared-statements

it should be:

fetch($fetchMode)

instead of

fetch($fetchStyle)

with a list of options (constants) ...

@doctrinebot

Comment created by jmontoya:

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

jmontoyaa@d3a4458

@doctrinebot

Comment created by @deeky666:

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...

@doctrinebot

Comment created by @deeky666:

Documentation fixed in commit: 7fc6b42

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added the Bug label Dec 6, 2015
@Ocramius Ocramius was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.5 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment