Doctrine 1
  1. Doctrine 1
  2. DC-900

HYDRATE_SINGLE_SCALAR option always returns false

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Ubuntu Linux Karmic, Apache 2, Symfony 1.4.3

      Description

      I notice that the fetchone with HYDRATE_SINGLE_SCALAR option always returns false as the return to the $collection object is a string type, this is returned by the hydrateResultSet with driver mode set to 6 (I assume this is for scalar values)

      My code is a two table query with which returns a string of "10" (g.id in query below) and returns false because it is not a doctrine collection, I did check the doctrine examples and it seems to be the way its used. Not sure if its the doctrine version issue with symfony, my code or an actual bug

      $q = Doctrine_Core::getTable('ClipGroup')
      ->createQuery('g')
      ->select('g.id')
      ->leftJoin('g.sfGuardUser u')
      ->Where('g.completed_at IS NULL')
      ->andWhere('g.expires_at > ?', date('Y-m-d H:i:s', time()))
      ->andWhere('u.id = ?', $userId);
      return $q->fetchOne(array(), Doctrine_Core::HYDRATE_SINGLE_SCALAR);

      I am using doctrine included in symfony 1.4.3, here is the comment on the Query.php file * @version $Revision: 6792 $,
      public function fetchOne($params = array(), $hydrationMode = null)
      {
      $collection = $this->execute($params, $hydrationMode);

      if (count($collection) === 0)

      { return false; }

      if ($collection instanceof Doctrine_Collection)

      { return $collection->getFirst(); }

      else if (is_array($collection))

      { return array_shift($collection); }

      return false;
      }

      Hydrator.php - returns a string * @version $Revision: 3192 $

      public function hydrateResultSet($stmt, $tableAliases)

      { $driver = $this->getHydratorDriver($this->_hydrationMode, $tableAliases); $result = $driver->hydrateResultSet($stmt); return $result; }

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Junaid Ebrahim
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: