Exemplo n.º 1
0
 /**
  * The returned array will contain objects of the default type or
  * objects that inherit from the default.
  *
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function populateObjects(PDOStatement $stmt)
 {
     $results = array();
     // set the class once to avoid overhead in the loop
     $cls = MessagePeer::getOMClass(false);
     // populate the object(s)
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key = MessagePeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj = MessagePeer::getInstanceFromPool($key))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://www.propelorm.org/ticket/509
             // $obj->hydrate($row, 0, true); // rehydrate
             $results[] = $obj;
         } else {
             $obj = new $cls();
             $obj->hydrate($row);
             $results[] = $obj;
             MessagePeer::addInstanceToPool($obj, $key);
         }
         // if key exists
     }
     $stmt->closeCursor();
     return $results;
 }
 /**
  * Selects a collection of Message objects pre-filled with all related objects except Production.
  *
  * @return     array Array of Message objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptProduction(Criteria $c, $con = null)
 {
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     // $c->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     MessagePeer::addSelectColumns($c);
     $startcol2 = MessagePeer::NUM_COLUMNS - MessagePeer::NUM_LAZY_LOAD_COLUMNS + 1;
     UserPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + UserPeer::NUM_COLUMNS;
     $c->addJoin(MessagePeer::USER_ID, UserPeer::USER_ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = MessagePeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = UserPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($rs, $startcol2);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj2 = $temp_obj1->getUser();
             //CHECKME
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addMessage($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initMessages();
             $obj2->addMessage($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }
Exemplo n.º 3
0
 /**
  * Selects a collection of Message objects pre-filled with all related objects except UserRelatedByOwnerId.
  *
  * @param      Criteria  $c
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of Message objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptUserRelatedByOwnerId(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     // $c->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     MessagePeer::addSelectColumns($c);
     $startcol2 = MessagePeer::NUM_COLUMNS - MessagePeer::NUM_LAZY_LOAD_COLUMNS;
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = MessagePeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = MessagePeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $omClass = MessagePeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             MessagePeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Exemplo n.º 4
0
 public static function doSelectJoinAllExceptsfGuardUserRelatedByRecipientId(Criteria $c, $con = null)
 {
     foreach (sfMixer::getCallables('BaseMessagePeer:doSelectJoinAllExcept:doSelectJoinAllExcept') as $callable) {
         call_user_func($callable, 'BaseMessagePeer', $c, $con);
     }
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     MessagePeer::addSelectColumns($c);
     $startcol2 = MessagePeer::NUM_COLUMNS - MessagePeer::NUM_LAZY_LOAD_COLUMNS + 1;
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = MessagePeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $results[] = $obj1;
     }
     return $results;
 }