Esempio n. 1
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = EleccionI18nPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setCulture($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setNombreCorto($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setNombre($arr[$keys[3]]);
     }
 }
Esempio n. 2
0
 /**
  * Returns the current translation.
  *
  * @return EleccionI18n
  */
 public function getCurrentEleccionI18n($culture = null)
 {
     if (null === $culture) {
         $culture = null === $this->culture ? sfPropel::getDefaultCulture() : $this->culture;
     }
     if (!isset($this->current_i18n[$culture])) {
         $object = $this->isNew() ? null : EleccionI18nPeer::retrieveByPK($this->getPrimaryKey(), $culture);
         if ($object) {
             $this->setEleccionI18nForCulture($object, $culture);
         } else {
             $this->setEleccionI18nForCulture(new EleccionI18n(), $culture);
             $this->current_i18n[$culture]->setCulture($culture);
         }
     }
     return $this->current_i18n[$culture];
 }
Esempio n. 3
0
 /**
  * Selects a collection of {@link Eleccion} objects with a {@link EleccionI18n} 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);
     }
     EleccionPeer::addSelectColumns($criteria);
     $startcol = EleccionPeer::NUM_COLUMNS - EleccionPeer::NUM_LAZY_LOAD_COLUMNS;
     EleccionI18nPeer::addSelectColumns($criteria);
     $criteria->addJoin(EleccionPeer::ID, EleccionI18nPeer::ID, $join_behavior);
     $criteria->add(EleccionI18nPeer::CULTURE, $culture);
     foreach (sfMixer::getCallables('BaseEleccion:doSelectJoin:doSelectJoin') as $sf_hook) {
         call_user_func($sf_hook, 'Eleccion', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = EleccionPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = EleccionPeer::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 = EleccionPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             EleccionPeer::addInstanceToPool($obj1, $key1);
         }
         // if $obj1 already loaded
         $key2 = EleccionI18nPeer::getPrimaryKeyHashFromRow($row, $startcol);
         if ($key2 !== null) {
             $obj2 = EleccionI18nPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = EleccionI18nPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol);
                 EleccionI18nPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 already loaded
             $obj1->setEleccionI18nForCulture($obj2, $culture);
         }
         // if joined row was not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Esempio n. 4
0
 /**
  * Retrieve object using using composite pkey values.
  * @param      int $id
  * @param      string $culture
  * @param      PropelPDO $con
  * @return     EleccionI18n
  */
 public static function retrieveByPK($id, $culture, PropelPDO $con = null)
 {
     $key = serialize(array((string) $id, (string) $culture));
     if (null !== ($obj = EleccionI18nPeer::getInstanceFromPool($key))) {
         return $obj;
     }
     if ($con === null) {
         $con = Propel::getConnection(EleccionI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $criteria = new Criteria(EleccionI18nPeer::DATABASE_NAME);
     $criteria->add(EleccionI18nPeer::ID, $id);
     $criteria->add(EleccionI18nPeer::CULTURE, $culture);
     $v = EleccionI18nPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }