Fork me on GitHub

Doctrine 2: Select distinct ?  Bottom

  • Hi,

    can someone who is more familiar with Doctrine 2 tell me how to code the following query using the Doctrine way of doing things:

    Code

    sql = "SELECT DISTINCT
                      $handlersColumn[handler],
                      $handlersColumn[title]
                    FROM $handlersTable"
    ;

            $result = $dbconn->execute($sql);
            $handlers = array();
            for (; !$result->EOF; $result->MoveNext()) {
                $handler = array('handler'    => $result->fields[0],
                                 'title'      => $result->fields[1],
                                 'mediaTypes' => array());
       
                $handlers[] = $handler;
            }
            $result->Close();


    Any hints are much appreciated.

    Greetings/Thanks
    Robert
  • you can use raw SQL if you must.

    doctrine docs

    I did it here:

    Tag module

    DQL also can use select DISTINCT see this doctrine doc page
  • OK, thanks, that's what I thought ... I just wanted to know if there was a smarter way of doing things ...

    Greetings
    R
  • DQL is the smarter way. Specific examples can be found on the page Craig posted at http://www.doctrine-project.org/docs/orm/2.1/en/reference/dql-doctrine-query-language.html#DQL-select-examples

    Drak

    --
    Zikula Lead Developer
    Board Member of the Zikula Foundation
    Follow me on twitter.com/zikuladrak
  • 0 users

This list is based on users active over the last 60 minutes.