/** * Selects a collection of {@link Movie} objects with a {@link MovieI18n} translation populated. * * @param Criteria $criteria * @param string $culture * @param PropelPDO $con * @param string $join_behavior * * @return array */ public static function doSelectWithI18n(Criteria $criteria, $culture = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; if (null === $culture) { $culture = sfPropel::getDefaultCulture(); } // Set the correct dbName if it has not been overridden if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(self::DATABASE_NAME); } MoviePeer::addSelectColumns($criteria); $startcol = MoviePeer::NUM_COLUMNS - MoviePeer::NUM_LAZY_LOAD_COLUMNS; MovieI18nPeer::addSelectColumns($criteria); $criteria->addJoin(MoviePeer::ID, MovieI18nPeer::ID, $join_behavior); $criteria->add(MovieI18nPeer::CULTURE, $culture); foreach (sfMixer::getCallables('BaseMovie:doSelectJoin:doSelectJoin') as $sf_hook) { call_user_func($sf_hook, 'Movie', $criteria, $con); } $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = MoviePeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = MoviePeer::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 = MoviePeer::getOMClass(false); $obj1 = new $cls(); $obj1->hydrate($row); MoviePeer::addInstanceToPool($obj1, $key1); } // if $obj1 already loaded $key2 = MovieI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); if ($key2 !== null) { $obj2 = MovieI18nPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = MovieI18nPeer::getOMClass(false); $obj2 = new $cls(); $obj2->hydrate($row, $startcol); MovieI18nPeer::addInstanceToPool($obj2, $key2); } // if obj2 already loaded $obj1->setMovieI18nForCulture($obj2, $culture); } // if joined row was not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Retrieve object using using composite pkey values. * @param int $id * @param string $culture * @param PropelPDO $con * @return MovieI18n */ public static function retrieveByPK($id, $culture, PropelPDO $con = null) { $key = serialize(array((string) $id, (string) $culture)); if (null !== ($obj = MovieI18nPeer::getInstanceFromPool($key))) { return $obj; } if ($con === null) { $con = Propel::getConnection(MovieI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria = new Criteria(MovieI18nPeer::DATABASE_NAME); $criteria->add(MovieI18nPeer::ID, $id); $criteria->add(MovieI18nPeer::CULTURE, $culture); $v = MovieI18nPeer::doSelect($criteria, $con); return !empty($v) ? $v[0] : null; }