public static function getInstanceFromIdPool($key) { if (Propel::isInstancePoolingEnabled() && isset(self::$assetInstancesById[$key])) { return self::$assetInstancesById[$key]; } return null; }
/** * @param string $entityType * @param string $path * @return bool */ public static function doesPathExist($entityType, $path) { $path = static::_normalize($path); $pathKey = self::_pathKey($entityType, $path); if (\Propel::isInstancePoolingEnabled() && ($obj = static::getInstanceFromPool($pathKey))) { return true; } $count = EntryQuery::create($entityType)->filterByPath($path)->count(); return $count > 0; }
public function testInstancePoolingReenabled() { Propel::enableInstancePooling(); $books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find($this->con); foreach ($books as $book) { } $this->assertTrue(Propel::isInstancePoolingEnabled()); Propel::disableInstancePooling(); $books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find($this->con); foreach ($books as $book) { } $this->assertFalse(Propel::isInstancePoolingEnabled()); Propel::enableInstancePooling(); }
/** * Populate the database using all the Entity classes previously added. * * @param PropelPDO $con A Propel connection object * * @return array A list of the inserted PKs */ public function execute($con = null) { if (null === $con) { $con = $this->getConnection(); } $isInstancePoolingEnabled = \Propel::isInstancePoolingEnabled(); \Propel::disableInstancePooling(); $insertedEntities = array(); $con->beginTransaction(); foreach ($this->quantities as $class => $number) { for ($i = 0; $i < $number; $i++) { $insertedEntities[$class][] = $this->entities[$class]->execute($con, $insertedEntities); } } $con->commit(); if ($isInstancePoolingEnabled) { \Propel::enableInstancePooling(); } return $insertedEntities; }
public function format(PDOStatement $stmt) { $this->checkInit(); if ($class = $this->collectionName) { $collection = new $class(); $collection->setModel($this->class); $collection->setFormatter($this); } else { $collection = array(); } if ($this->isWithOneToMany()) { if ($this->hasLimit) { throw new PropelException('Cannot use limit() in conjunction with with() on a one-to-many relationship. Please remove the with() call, or the limit() call.'); } $pks = array(); $objectsByPks = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $object = $this->getAllObjectsFromRow($row); $pk = $object->getPrimaryKey(); if (false === Propel::isInstancePoolingEnabled()) { if (isset($objectsByPks[$pk])) { $this->mainObject = $objectsByPks[$pk]; $object = $this->getAllObjectsFromRow($row); } $objectsByPks[$pk] = $object; } if (!in_array($pk, $pks)) { $collection[] = $object; $pks[] = $pk; } } } else { // only many-to-one relationships while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $collection[] = $this->getAllObjectsFromRow($row); } } $stmt->closeCursor(); return $collection; }
public function testSetUp() { $this->assertTrue(Propel::isInstancePoolingEnabled()); $this->assertEquals(2, count($this->author->getBooks())); $this->assertEquals(2, $this->author->countBooks()); }
/** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. * * For tables with a single-column primary key, that simple pkey value will be returned. For tables with * a multi-column primary key, a serialize()d version of the primary key will be returned. * * @param string $key The key (@see getPrimaryKeyHash()) for this instance. * @return Empleadofacturacion Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. * @see getPrimaryKeyHash() */ public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(EmpleadofacturacionPeer::$instances[$key])) { return EmpleadofacturacionPeer::$instances[$key]; } } return null; // just to be explicit }
/** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. * * For tables with a single-column primary key, that simple pkey value will be returned. For tables with * a multi-column primary key, a serialize()d version of the primary key will be returned. * * @param string $key The key (@see getPrimaryKeyHash()) for this instance. * @return GalleryImageSize Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. * @see getPrimaryKeyHash() */ public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(GalleryImageSizePeer::$instances[$key])) { return GalleryImageSizePeer::$instances[$key]; } } return null; // just to be explicit }
/** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. * * For tables with a single-column primary key, that simple pkey value will be returned. For tables with * a multi-column primary key, a serialize()d version of the primary key will be returned. * * @param string $key The key (@see getPrimaryKeyHash()) for this instance. * @return Procedimientregrogramado Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. * @see getPrimaryKeyHash() */ public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(ProcedimientregrogramadoPeer::$instances[$key])) { return ProcedimientregrogramadoPeer::$instances[$key]; } } return null; // just to be explicit }
/** * Makes an additional query to populate the objects related to the collection objects * by a certain relation * * @param string $relation Relation name (e.g. 'Book') * @param Criteria $criteria Optional Criteria object to filter the related object collection * @param PropelPDO $con Optional connection object * * @return PropelObjectCollection The list of related objects * * @throws PropelException */ public function populateRelation($relation, $criteria = null, $con = null) { if (!Propel::isInstancePoolingEnabled()) { throw new PropelException('populateRelation() needs instance pooling to be enabled prior to populating the collection'); } $relationMap = $this->getFormatter()->getTableMap()->getRelation($relation); if ($this->isEmpty()) { // save a useless query and return an empty collection $coll = new PropelObjectCollection(); $coll->setModel($relationMap->getRightTable()->getClassname()); return $coll; } $symRelationMap = $relationMap->getSymmetricalRelation(); $query = PropelQuery::from($relationMap->getRightTable()->getClassname()); if (null !== $criteria) { $query->mergeWith($criteria); } // query the db for the related objects $filterMethod = 'filterBy' . $symRelationMap->getName(); $relatedObjects = $query->{$filterMethod}($this)->find($con); if ($relationMap->getType() == RelationMap::ONE_TO_MANY) { // initialize the embedded collections of the main objects $relationName = $relationMap->getName(); foreach ($this as $mainObj) { $mainObj->initRelation($relationName); } // associate the related objects to the main objects $getMethod = 'get' . $symRelationMap->getName(); $addMethod = 'add' . $relationName; foreach ($relatedObjects as $object) { $mainObj = $object->{$getMethod}(); // instance pool is used here to avoid a query $mainObj->{$addMethod}($object); } $relatedObjects->clearIterator(); } elseif ($relationMap->getType() == RelationMap::MANY_TO_ONE) { // nothing to do; the instance pool will catch all calls to getRelatedObject() // and return the object in memory } else { throw new PropelException('populateRelation() does not support this relation type'); } return $relatedObjects; }
/** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. * * For tables with a single-column primary key, that simple pkey value will be returned. For tables with * a multi-column primary key, a serialize()d version of the primary key will be returned. * * @param string $key The key (@see getPrimaryKeyHash()) for this instance. * @return Proveedoritradeservicio Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. * @see getPrimaryKeyHash() */ public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(ProveedoritradeservicioPeer::$instances[$key])) { return ProveedoritradeservicioPeer::$instances[$key]; } } return null; // just to be explicit }
/** * Reload all already loaded nodes to sync them with updated db * * @param sfAssetFolder $node Propel object for parent node * @param int $delta Value to be shifted by, can be negative * @param PropelPDO $con Connection to use. */ protected static function updateLoadedNode(NodeObject $node, $delta, PropelPDO $con = null) { if (Propel::isInstancePoolingEnabled()) { $keys = array(); foreach (self::$instances as $obj) { $keys[] = $obj->getPrimaryKey(); } if (!empty($keys)) { // We don't need to alter the object instance pool; we're just modifying these ones // already in the pool. $criteria = new Criteria(self::DATABASE_NAME); $criteria->add(sfAssetFolderPeer::ID, $keys, Criteria::IN); $stmt = sfAssetFolderPeer::doSelectStmt($criteria, $con); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key = sfAssetFolderPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($object = sfAssetFolderPeer::getInstanceFromPool($key))) { $object->setLeftValue($row[1]); $object->setRightValue($row[2]); } } $stmt->closeCursor(); } } }
/** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. * * For tables with a single-column primary key, that simple pkey value will be returned. For tables with * a multi-column primary key, a serialize()d version of the primary key will be returned. * * @param string $key The key (@see getPrimaryKeyHash()) for this instance. * @return SubscriberGroupMembership Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. * @see getPrimaryKeyHash() */ public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(SubscriberGroupMembershipPeer::$instances[$key])) { return SubscriberGroupMembershipPeer::$instances[$key]; } } return null; // just to be explicit }
/** * Makes an additional query to populate the objects related to the collection objects * by a certain relation * * @param string $relation Relation name (e.g. 'Book') * @param Criteria $criteria Optional Criteria object to filter the related object collection * @param PropelPDO $con Optional connection object * * @return PropelObjectCollection the list of related objects */ public function populateRelation($relation, $criteria = null, $con = null) { if (!Propel::isInstancePoolingEnabled()) { throw new PropelException('populateRelation() needs instance pooling to be enabled prior to populating the collection'); } $relationMap = $this->getFormatter()->getTableMap()->getRelation($relation); $symRelationMap = $relationMap->getSymmetricalRelation(); // query the db for the related objects $useMethod = 'use' . $symRelationMap->getName() . 'Query'; $query = PropelQuery::from($relationMap->getRightTable()->getPhpName()); if (null !== $criteria) { $query->mergeWith($criteria); } $relatedObjects = $query->{$useMethod}()->filterByPrimaryKeys($this->getPrimaryKeys())->endUse()->find($con); // associate the related objects to the main objects if ($relationMap->getType() == RelationMap::ONE_TO_MANY) { $getMethod = 'get' . $symRelationMap->getName(); $addMethod = 'add' . $relationMap->getName(); foreach ($relatedObjects as $object) { $mainObj = $object->{$getMethod}(); // instance pool is used here to avoid a query $mainObj->{$addMethod}($object); } } elseif ($relationMap->getType() == RelationMap::MANY_TO_ONE) { // nothing to do; the instance pool will catch all calls to getRelatedObject() // and return the object in memory } else { throw new PropelException('populateRelation() does not support this relation type'); } return $relatedObjects; }
/** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. * * For tables with a single-column primary key, that simple pkey value will be returned. For tables with * a multi-column primary key, a serialize()d version of the primary key will be returned. * * @param string $key The key (@see getPrimaryKeyHash()) for this instance. * @return LanguageObjectHistory Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. * @see getPrimaryKeyHash() */ public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(LanguageObjectHistoryPeer::$instances[$key])) { return LanguageObjectHistoryPeer::$instances[$key]; } } return null; // just to be explicit }
/** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. * * For tables with a single-column primary key, that simple pkey value will be returned. For tables with * a multi-column primary key, a serialize()d version of the primary key will be returned. * * @param string $key The key (@see getPrimaryKeyHash()) for this instance. * @return DetailBarangMasuk Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. * @see getPrimaryKeyHash() */ public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(DetailBarangMasukPeer::$instances[$key])) { return DetailBarangMasukPeer::$instances[$key]; } } return null; // just to be explicit }
/** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. * * For tables with a single-column primary key, that simple pkey value will be returned. For tables with * a multi-column primary key, a serialize()d version of the primary key will be returned. * * @param string $key The key (@see getPrimaryKeyHash()) for this instance. * @return DocumentCategory Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. * @see getPrimaryKeyHash() */ public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(DocumentCategoryPeer::$instances[$key])) { return DocumentCategoryPeer::$instances[$key]; } } return null; // just to be explicit }
/** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. * * For tables with a single-column primary key, that simple pkey value will be returned. For tables with * a multi-column primary key, a serialize()d version of the primary key will be returned. * * @param string $key The key (@see getPrimaryKeyHash()) for this instance. * @return Expedientearchivo Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. * @see getPrimaryKeyHash() */ public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(ExpedientearchivoPeer::$instances[$key])) { return ExpedientearchivoPeer::$instances[$key]; } } return null; // just to be explicit }
/** * Reload all already loaded nodes to sync them with updated db * * @param Especialidad $prune Object to prune from the update * @param PropelPDO $con Connection to use. */ public static function updateLoadedNodes($prune = null, PropelPDO $con = null) { if (Propel::isInstancePoolingEnabled()) { $keys = array(); foreach (EspecialidadPeer::$instances as $obj) { if (!$prune || !$prune->equals($obj)) { $keys[] = $obj->getPrimaryKey(); } } if (!empty($keys)) { // We don't need to alter the object instance pool; we're just modifying these ones // already in the pool. $criteria = new Criteria(EspecialidadPeer::DATABASE_NAME); $criteria->add(EspecialidadPeer::ID, $keys, Criteria::IN); $stmt = EspecialidadPeer::doSelectStmt($criteria, $con); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key = EspecialidadPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($object = EspecialidadPeer::getInstanceFromPool($key))) { $object->setLeftValue($row[6]); $object->setRightValue($row[7]); $object->setLevel($row[8]); $object->clearNestedSetChildren(); } } $stmt->closeCursor(); } } }
/** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. * * For tables with a single-column primary key, that simple pkey value will be returned. For tables with * a multi-column primary key, a serialize()d version of the primary key will be returned. * * @param string $key The key (@see getPrimaryKeyHash()) for this instance. * @return sfGuardGroupPermission Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. * @see getPrimaryKeyHash() */ public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(sfGuardGroupPermissionPeer::$instances[$key])) { return sfGuardGroupPermissionPeer::$instances[$key]; } } return null; // just to be explicit }
/** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. * * For tables with a single-column primary key, that simple pkey value will be returned. For tables with * a multi-column primary key, a serialize()d version of the primary key will be returned. * * @param string $key The key (@see getPrimaryKeyHash()) for this instance. * @return Articulovariantereorden Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. * @see getPrimaryKeyHash() */ public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(ArticulovariantereordenPeer::$instances[$key])) { return ArticulovariantereordenPeer::$instances[$key]; } } return null; // just to be explicit }
/** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. * * For tables with a single-column primary key, that simple pkey value will be returned. For tables with * a multi-column primary key, a serialize()d version of the primary key will be returned. * * @param string $key The key (@see getPrimaryKeyHash()) for this instance. * @return UcUserPermissionMatches Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. * @see getPrimaryKeyHash() */ public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(UcUserPermissionMatchesPeer::$instances[$key])) { return UcUserPermissionMatchesPeer::$instances[$key]; } } return null; // just to be explicit }
/** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. * * For tables with a single-column primary key, that simple pkey value will be returned. For tables with * a multi-column primary key, a serialize()d version of the primary key will be returned. * * @param string $key The key (@see getPrimaryKeyHash()) for this instance. * @return Cajachicadetalle Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. * @see getPrimaryKeyHash() */ public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(CajachicadetallePeer::$instances[$key])) { return CajachicadetallePeer::$instances[$key]; } } return null; // just to be explicit }
/** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. * * For tables with a single-column primary key, that simple pkey value will be returned. For tables with * a multi-column primary key, a serialize()d version of the primary key will be returned. * * @param string $key The key (@see getPrimaryKeyHash()) for this instance. * @return Diagnosticocirugia Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. * @see getPrimaryKeyHash() */ public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(DiagnosticocirugiaPeer::$instances[$key])) { return DiagnosticocirugiaPeer::$instances[$key]; } } return null; // just to be explicit }
/** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. * * For tables with a single-column primary key, that simple pkey value will be returned. For tables with * a multi-column primary key, a serialize()d version of the primary key will be returned. * * @param string $key The key (@see getPrimaryKeyHash()) for this instance. * @return ExamCommentDig Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled. * @see getPrimaryKeyHash() */ public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(self::$instances[$key])) { return self::$instances[$key]; } } return null; // just to be explicit }
/** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. * * For tables with a single-column primary key, that simple pkey value will be returned. For tables with * a multi-column primary key, a serialize()d version of the primary key will be returned. * * @param string $key The key (@see getPrimaryKeyHash()) for this instance. * @return Medicoespecialidad Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. * @see getPrimaryKeyHash() */ public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(MedicoespecialidadPeer::$instances[$key])) { return MedicoespecialidadPeer::$instances[$key]; } } return null; // just to be explicit }