Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-544

Where's the Query::HYDRATE_BOTH constant?

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.4
    • Fix Version/s: 2.5
    • Component/s: None
    • Environment:
      Doctrine 2.3.4 DBAL + ORM, using Silex

      Description

      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?

        Activity

        Julio Montoya created issue -
        Hide
        Marco Pivetta added a comment -

        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

        Show
        Marco Pivetta added a comment - 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
        Marco Pivetta made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Benjamin Eberlei [ beberlei ] Marco Pivetta [ ocramius ]
        Resolution Invalid [ 6 ]
        Hide
        Julio Montoya added a comment -

        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

        Show
        Julio Montoya added a comment - 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
        Marco Pivetta made changes -
        Resolution Invalid [ 6 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Hide
        Marco Pivetta added a comment - - edited

        Sorry, confused this one as an ORM issue.

        Show
        Marco Pivetta added a comment - - edited Sorry, confused this one as an ORM issue.
        Hide
        Marco Pivetta added a comment -

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

        Can you link the document that contains the imprecision?

        Show
        Marco Pivetta added a comment - Checked briefly - you should indeed use the `PDO::FETCH_*` constants. Can you link the document that contains the imprecision?
        Hide
        Julio Montoya added a comment -

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

        Show
        Julio Montoya added a comment - 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) ...
        Hide
        Julio Montoya added a comment -

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

        https://github.com/jmontoyaa/dbal/commit/d3a44589cdef6c146592eee2b2bd9f8907dadd1f

        Show
        Julio Montoya added a comment - Working in a PR but first we need to define those constants ... https://github.com/jmontoyaa/dbal/commit/d3a44589cdef6c146592eee2b2bd9f8907dadd1f
        Hide
        Steve Müller added a comment -

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

        Show
        Steve Müller added a comment - 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...
        Show
        Steve Müller added a comment - Documentation fixed in commit: https://github.com/doctrine/dbal/commit/7fc6b420a296504c56859f67ed1dc16a9a3bbdfe
        Steve Müller made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Fix Version/s 2.5 [ 10523 ]
        Resolution Fixed [ 1 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DBAL-544, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            Julio Montoya
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: