/** * Gets an array of Element objects which contain a foreign key that references this object. * * If this collection has already been initialized with an identical Criteria, it returns the collection. * Otherwise if this Category has previously been saved, it will retrieve * related Elements from storage. If this Category is new, it will return * an empty collection or the current collection, the criteria is ignored on a new object. * * @param PropelPDO $con * @param Criteria $criteria * @return array Element[] * @throws PropelException */ public function getElements($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(CategoryPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collElements === null) { if ($this->isNew()) { $this->collElements = array(); } else { $criteria->add(ElementPeer::CATEGORY_ID, $this->id); ElementPeer::addSelectColumns($criteria); $this->collElements = ElementPeer::doSelect($criteria, $con); } } else { // criteria has no effect for a new object if (!$this->isNew()) { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return the collection. $criteria->add(ElementPeer::CATEGORY_ID, $this->id); ElementPeer::addSelectColumns($criteria); if (!isset($this->lastElementCriteria) || !$this->lastElementCriteria->equals($criteria)) { $this->collElements = ElementPeer::doSelect($criteria, $con); } } } $this->lastElementCriteria = $criteria; return $this->collElements; }
/** * Selects a collection of Element objects pre-filled with all related objects. * * @return array Array of Element objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAll(Criteria $c, $con = null) { $c = clone $c; // Set the correct dbName if it has not been overridden if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } ElementPeer::addSelectColumns($c); $startcol2 = ElementPeer::NUM_COLUMNS - ElementPeer::NUM_LAZY_LOAD_COLUMNS + 1; ProductionPeer::addSelectColumns($c); $startcol3 = $startcol2 + ProductionPeer::NUM_COLUMNS; $c->addJoin(ElementPeer::PRODUCTION_ID, ProductionPeer::PRODUCTION_ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $omClass = ElementPeer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); // Add objects for joined Production rows $omClass = ProductionPeer::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->getProduction(); // CHECKME if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { $newObject = false; $temp_obj2->addElement($obj1); // CHECKME break; } } if ($newObject) { $obj2->initElements(); $obj2->addElement($obj1); } $results[] = $obj1; } return $results; }
/** * Selects a collection of Element objects pre-filled with all related objects except Company. * * @param Criteria $criteria * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of Element objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptCompany(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden // $criteria->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(self::DATABASE_NAME); } ElementPeer::addSelectColumns($criteria); $startcol2 = ElementPeer::NUM_COLUMNS - ElementPeer::NUM_LAZY_LOAD_COLUMNS; CategoryPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + (CategoryPeer::NUM_COLUMNS - CategoryPeer::NUM_LAZY_LOAD_COLUMNS); ElementStatusPeer::addSelectColumns($criteria); $startcol4 = $startcol3 + (ElementStatusPeer::NUM_COLUMNS - ElementStatusPeer::NUM_LAZY_LOAD_COLUMNS); $criteria->addJoin(ElementPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); $criteria->addJoin(ElementPeer::ELEMENT_STATUS_ID, ElementStatusPeer::ID, $join_behavior); // symfony_behaviors behavior foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) { call_user_func($sf_hook, 'BaseElementPeer', $criteria, $con); } $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = ElementPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = ElementPeer::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 { $cls = ElementPeer::getOMClass(false); $obj1 = new $cls(); $obj1->hydrate($row); ElementPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Category rows $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = CategoryPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = CategoryPeer::getOMClass(false); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); CategoryPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (Element) to the collection in $obj2 (Category) $obj2->addElement($obj1); } // if joined row is not null // Add objects for joined ElementStatus rows $key3 = ElementStatusPeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = ElementStatusPeer::getInstanceFromPool($key3); if (!$obj3) { $cls = ElementStatusPeer::getOMClass(false); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); ElementStatusPeer::addInstanceToPool($obj3, $key3); } // if $obj3 already loaded // Add the $obj1 (Element) to the collection in $obj3 (ElementStatus) $obj3->addElement($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this Production has previously * been saved, it will retrieve related Elements from storage. * If this Production is new, it will return * an empty collection or the current collection, the criteria * is ignored on a new object. * * @param Connection $con * @param Criteria $criteria * @throws PropelException */ public function getElements($criteria = null, $con = null) { // include the Peer class include_once 'src/model/whiteboard/om/BaseElementPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collElements === null) { if ($this->isNew()) { $this->collElements = array(); } else { $criteria->add(ElementPeer::PRODUCTION_ID, $this->getProductionId()); ElementPeer::addSelectColumns($criteria); $this->collElements = ElementPeer::doSelect($criteria, $con); } } else { // criteria has no effect for a new object if (!$this->isNew()) { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return the collection. $criteria->add(ElementPeer::PRODUCTION_ID, $this->getProductionId()); ElementPeer::addSelectColumns($criteria); if (!isset($this->lastElementCriteria) || !$this->lastElementCriteria->equals($criteria)) { $this->collElements = ElementPeer::doSelect($criteria, $con); } } } $this->lastElementCriteria = $criteria; return $this->collElements; }