Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-577

AbstractPlatform::getInExpression calls non-existent method AbstractPlatform::getIdentifiers

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.4
    • Fix Version/s: None
    • Component/s: Platforms
    • Security Level: All
    • Labels:
      None

      Description

      The method AbstractPlatform::getInExpression($column, $values) still calls the non-existent method AbstractPlatform::getIdentifiers($values). This prevents the use of this method causing a brutal PHP failure. Why not pass the identifiers array instead of the values array, until the method is implemented?

        Activity

        Hide
        Giovanni Lovato added a comment - - edited

        I really don't see the meaning of AbstractPlatform::getIdentifiers.
        For example, suppose I want to find all rows where field 'tag' is in ['foo', 'bar', 'baz'], I would use getInExpression like this:

        $array = array('foo', 'bar', 'baz');
        $queryBuilder = $this->conn->createQueryBuilder();
        $placeholders = array_map(array($queryBuilder, 'createNamedParameter'), $array);
        $field = $this->link->quoteIdentifier('tag');
        $inExpression = $this->conn->getDatabasePlatform()->getInExpression($field, $placeholders);
        $result = $queryBuilder->select('*')->from('table', 't)->where($inExpression)->execute();
        

        which works perfectly fine without any need of calling a getIdentifiers method.

        Show
        Giovanni Lovato added a comment - - edited I really don't see the meaning of AbstractPlatform::getIdentifiers. For example, suppose I want to find all rows where field 'tag' is in ['foo', 'bar', 'baz'] , I would use getInExpression like this: $array = array('foo', 'bar', 'baz'); $queryBuilder = $this->conn->createQueryBuilder(); $placeholders = array_map(array($queryBuilder, 'createNamedParameter'), $array); $field = $this->link->quoteIdentifier('tag'); $inExpression = $this->conn->getDatabasePlatform()->getInExpression($field, $placeholders); $result = $queryBuilder->select('*')->from('table', 't)->where($inExpression)->execute(); which works perfectly fine without any need of calling a getIdentifiers method.
        Hide
        Benjamin Eberlei added a comment -

        Code was removed, as it was a leftover from Doctrine 1.* times.

        Show
        Benjamin Eberlei added a comment - Code was removed, as it was a leftover from Doctrine 1.* times.
        Hide
        Giovanni Lovato added a comment -

        The whole getInExpression method was removed? How to build a IN-expression abstracting from platform now? The method worked, expect for a call to a non-existant AbstractPlatform::getIdentifiers.

        Show
        Giovanni Lovato added a comment - The whole getInExpression method was removed? How to build a IN-expression abstracting from platform now? The method worked, expect for a call to a non-existant AbstractPlatform::getIdentifiers.
        Hide
        Benjamin Eberlei added a comment -

        The method did not work, because it was impossible to implement "getIdentifiers" at that point. You can build an IN expression by binding to a statement with "$statement->bindValue(1, $array, \Doctrine\DBAL\Connection::PARAM_INT_ARRAY);" or PARAM_STR_ARRAY.

        Alternatively you can do: implode(", ", array_map(array($connection, 'quote'), $values));

        Show
        Benjamin Eberlei added a comment - The method did not work, because it was impossible to implement "getIdentifiers" at that point. You can build an IN expression by binding to a statement with "$statement->bindValue(1, $array, \Doctrine\DBAL\Connection::PARAM_INT_ARRAY);" or PARAM_STR_ARRAY. Alternatively you can do: implode(", ", array_map(array($connection, 'quote'), $values));

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Giovanni Lovato
          • Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: