Doctrine 1
  1. Doctrine 1
  2. DC-876

Basic Request return one element.

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.3
    • Fix Version/s: None
    • Component/s: Query
    • Labels:
      None
    • Environment:
      Windows XP Pro. Service Pack 3, Eclipe PDT, Doctrine 1.2.3, Php 5.2.11

      Description

      i try to get all preferences with an IdUser specified.

      schema.yml
      UserHasPreference:
        connection: hopscore
        actAs:
          I18n:
            fields: [value]
          Timestampable:
            created:
              name: created_at
              type: timestamp
              format: Y-m-d H:i:s
        columns:
          idUserHasPreference:
            name: idUserHasPreference as id
            type: integer(4)
            unsigned: true
            primary: true
            autoincrement: true
          UsersIdUser:
            name: UsersIdUser as idUser
            type: integer(4)
            unsigned: true
            notnull: true
          PreferencesIdPreference:
            name: PreferencesIdPreference as idPreference
            type: integer(4)
            unsigned: true
            notnull: true
          MatchLinksMatchLinkId:
            name: MatchLinksMatchLinkId as MatchLinkId
            type: integer(4)
            unsigned: true
            notnull: true
          value:
            type: string(100)
        relations:
          Users:
            class: User
            local: idUser
            foreign: id
            type: one
          Preferences:
            class: Preference
            local: idPreference
            foreign: id
            type: one
          MatchLinks:
            class: MatchLink
            local: MatchLinkId
            foreign: id
            type: one
        options:
          collate: utf8_unicode_ci
          charset: utf8
      
      Doctrine Request
      $preferences = Doctrine_Query::create()
      		->select('uhp.idPreference as idPref')
      		->addSelect('uhpt.value as value')
      		->addSelect('uhp.MatchLinkId as idItem')
      		->from('UserHasPreference uhp')
      		->innerJoin('uhp.Translation uhpt')
      		->where('uhp.idUser = ?', intval($idUser))
      		->execute(array(), Doctrine::HYDRATE_ARRAY);
      	    return $preferences;
      

      With $preferences->getSqlQuery(); and getParams(); and report this SQL query in phpmydadmin.
      With SQL i have 13 elements. But in my object $preference i have one element (Doctrine::HYDRATE_ARRAY)
      With "Doctrine::HYDRATE_NONE", i have 13 elements as SQL query.

        Activity

        Hide
        Eirik Hoem added a comment -

        I have the same problem, and I think this is related to the select statement. It seems that a select statement where all fields are aliased will cause this behavior. A simple work-around is to select one field without aliasing it.

        Code for reproducing / work-around:

        $query = Doctrine_Query::create();
        $query->from('Results r');
        $query->select('p.id as myid, r.value as foo');
        $query->innerJoin('r.Profil p on (r.pid=123)');
        $results = $query->execute(array(), Doctrine_Core::HYDRATE_ARRAY);

        count($results) = 1

        $query = Doctrine_Query::create();
        $query->from('Results r');
        $query->select('p.id as myid, r.value');
        $query->innerJoin('r.Profil p on (r.pid=123)');
        $results = $query->execute(array(), Doctrine_Core::HYDRATE_ARRAY);

        count($results) = 250

        Show
        Eirik Hoem added a comment - I have the same problem, and I think this is related to the select statement. It seems that a select statement where all fields are aliased will cause this behavior. A simple work-around is to select one field without aliasing it. Code for reproducing / work-around: $query = Doctrine_Query::create(); $query->from('Results r'); $query->select('p.id as myid, r.value as foo'); $query->innerJoin('r.Profil p on (r.pid=123)'); $results = $query->execute(array(), Doctrine_Core::HYDRATE_ARRAY); count($results) = 1 $query = Doctrine_Query::create(); $query->from('Results r'); $query->select('p.id as myid, r.value'); $query->innerJoin('r.Profil p on (r.pid=123)'); $results = $query->execute(array(), Doctrine_Core::HYDRATE_ARRAY); count($results) = 250

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            rudybruneau
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: