Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1952

Add support for array parameters on the SQLFilter

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: Git Master
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      The SQLFilter currently only accepts string parameters which would result in SQL like:

      "tableAlias.column = '$filterParameter'"
      

      To filter an Entity that has a lifecycle, this can be usefull to filter Entities that are in a specific state, for example:

      "tableAlias.state = 1"
      

      To be able to apply the filter on an Entity that can be in multiple states, it is usefull to be able to assign an array of states using setParameter:

      $allowedStates = array(1,2,3,4);
      $filter->setParameter('allowedStatesParam', $allowedStates);
      sprintf("tableAlias.state IN (%s)", implode(',', $this->getParameter('allowedStatesParam')));
      

      to eventually result in:

      "tableAlias.state IN (1,2,3,4)"
      

      However, this is currently not supported, it seems to go wrong on the PDO::quote() of the parameter. The SQL works ok when setting it statically in the filter, not taking the parameter into account.

      It would be nice to have support for arrays on the setParameter()

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Menno Holtkamp
          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated: