public function getItemsBaseOrdenados() { if (!$this->getPrimaryKey()) { return null; } if ($this->esTipoLista()) { $c = new Criteria(); $c->add(ItemBasePeer::ID_CAMPO, $this->getIdCampo()); $c->addAscendingOrderByColumn(ItemBasePeer::ORDEN); $items = ItemBasePeer::doSelect($c); return $items; } else { return null; } }
/** * Get the associated ItemBase object * * @param PropelPDO Optional Connection object. * @return ItemBase The associated ItemBase object. * @throws PropelException */ public function getItemBase(PropelPDO $con = null) { if ($this->aItemBase === null && $this->id_item_base !== null) { $c = new Criteria(ItemBasePeer::DATABASE_NAME); $c->add(ItemBasePeer::ID_ITEM_BASE, $this->id_item_base); $this->aItemBase = ItemBasePeer::doSelectOne($c, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aItemBase->addItems($this); */ } return $this->aItemBase; }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(ItemBasePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(ItemBasePeer::DATABASE_NAME); $criteria->add(ItemBasePeer::ID_ITEM_BASE, $pks, Criteria::IN); $objs = ItemBasePeer::doSelect($criteria, $con); } return $objs; }
/** * 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 = ItemBasePeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setIdItemBase($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setIdCampo($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setTexto($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setNumeroInferior($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setNumeroSuperior($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setAyuda($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setTextoAuxiliar($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setOrden($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setEsResponsableFichero($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setEsInconsistente($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setBorrado($arr[$keys[10]]); } }
protected function getItemOr404($id_item = 'id_item_base') { if (!$this->getRequestParameter($id_item)) { $this->forward404(); } else { $c = $this->getCriterio(); $c->addAnd(ItemBasePeer::ID_ITEM_BASE, $this->getRequestParameter($id_item)); $item = ItemBasePeer::doSelectOne($c); $this->forward404Unless($item); } return $item; }
public function __toString($to_file = false) { include_once SF_ROOT_DIR . "/lib/symfony/helper/DateHelper.php"; if (!$this->getPrimaryKey()) { return null; } $campo = $this->getItemBase()->getCampo(); $value = null; if (!$campo->esTipoLista()) { if ($campo->esTipoTextoLargo()) { $value = $this->getTextoLargo(); } elseif ($campo->esTipoTextoCorto()) { $value = $this->getTextoCorto(); } elseif ($campo->esTipoDocumento()) { if ($this->getTextoCorto() != "") { $fname = explode("_", basename($this->getTextoCorto())); if (sizeof($fname) > 1) { $fname = substr(basename($this->getTextoCorto()), strlen($fname[0]) + 1); } else { $fname = $fname[0]; } if ($to_file) { $value = $fname; } else { $value = "<a href=\"" . dirname(UsuarioPeer::getRuta()) . "/index.php/formularios/download/?id_item=" . $this->getIdItem() . "&id_formulario=" . $this->getIdFormulario() . "\" target=\"_NEW\">" . $fname . "<a>"; } } else { $value = ""; } } elseif ($campo->esTipoNumero()) { $value = $this->getNumero(); } elseif ($campo->esTipoFecha()) { $value = format_date($this->getFecha(), "D"); } elseif ($campo->esTipoBooleano()) { if ($this->getSiNo()) { $value = sfContext::getInstance()->getI18N()->__("SI"); } else { $value = sfContext::getInstance()->getI18N()->__("NO"); } } elseif ($campo->esTipoSelectPeriodo()) { $value = nombre_periodo($campo->getTipoPeriodo(), $this->getNumero(), $this->getAnio()); } elseif ($campo->esTipoTabla()) { $form = FormularioPeer::retrieveByPk($this->getIdTabla()); if ($form != null) { $value = $form->__toString(); } else { $value = "--"; } } elseif ($campo->esTipoObjeto()) { eval("\$value = " . $campo->getValorObjeto() . "Peer::retrieveByPk(\$this->getIdObjeto());"); if ($value != null) { $value = $value->__toString(); } else { $value = "--"; } } } else { //Obtener los items del mismo formulario cuyo campo id_campo coincida con el de nuestro id_item_base $c = new Criteria(); $c->addAnd(ItemPeer::ID_FORMULARIO, $this->getIdFormulario(), Criteria::EQUAL); $c->addAnd(ItemPeer::SI_NO, 1, Criteria::EQUAL); $c->addJoin(ItemPeer::ID_ITEM_BASE, ItemBasePeer::ID_ITEM_BASE, Criteria::JOIN); $c->addAnd(ItemBasePeer::ID_CAMPO, $this->getItemBase()->getIdCampo(), Criteria::EQUAL); $items_base_seleccionados = ItemBasePeer::doSelect($c); if (sizeof($items_base_seleccionados)) { $value .= !$to_file ? "<ul class=\"sf_admin_checklist\">\n" : ""; foreach ($items_base_seleccionados as $ibs) { $value .= !$to_file ? "<li>" : ""; /****/ if ($campo->esListaTipoRangos()) { //lista de rangos $desde = null; $hasta = null; $unidad = CampoPeer::getHtmlTipoUnidad($campo->getUnidadRangos()); $unidad = $unidad ? " " . $unidad : ''; if ($ibs->getNumeroInferior() && $ibs->getNumeroInferior() != '') { $desde = format_number($ibs->getNumeroInferior()) . $unidad; } if ($ibs->getNumeroSuperior() && $ibs->getNumeroSuperior() != '') { $hasta = format_number($ibs->getNumeroSuperior()) . $unidad; } if ($desde && $hasta) { $value .= __('desde %1% hasta %2%', array('%1%' => $desde, '%2%' => $hasta)); } else { if ($desde) { $value .= __('más de %1%', array('%1%' => $desde)); } elseif ($hasta) { $value .= __('menos de %2%', array('%2%' => $hasta)); } else { $value .= null; } } } else { $value .= $ibs->getTexto(); } /****/ if ($ibs->getTextoAuxiliar()) { $texto_auxiliar = $this->getTextoAuxiliar() ? $this->getTextoAuxiliar() : null; $value .= isset($texto_auxiliar) ? " (" . $texto_auxiliar . ")" : ''; } $value .= !$to_file ? "</li>" : " - "; } $value .= !$to_file ? "</ul>\n" : ""; if (!$to_file) { $value = substr($value, 0, strlen($value) - 3); } } } return $value; }
/** * Selects a collection of Item objects pre-filled with all related objects except Formulario. * * @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 Item objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptFormulario(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); } ItemPeer::addSelectColumns($c); $startcol2 = ItemPeer::NUM_COLUMNS - ItemPeer::NUM_LAZY_LOAD_COLUMNS; ItemBasePeer::addSelectColumns($c); $startcol3 = $startcol2 + (ItemBasePeer::NUM_COLUMNS - ItemBasePeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(ItemPeer::ID_ITEM_BASE), array(ItemBasePeer::ID_ITEM_BASE), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = ItemPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = ItemPeer::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 = ItemPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); ItemPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined ItemBase rows $key2 = ItemBasePeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = ItemBasePeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = ItemBasePeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); ItemBasePeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (Item) to the collection in $obj2 (ItemBase) $obj2->addItem($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Returns the number of related ItemBase objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related ItemBase objects. * @throws PropelException */ public function countItemBases(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(CampoPeer::DATABASE_NAME); } else { $criteria = clone $criteria; } if ($distinct) { $criteria->setDistinct(); } $count = null; if ($this->collItemBases === null) { if ($this->isNew()) { $count = 0; } else { $criteria->add(ItemBasePeer::ID_CAMPO, $this->id_campo); $count = ItemBasePeer::doCount($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 count of the collection. $criteria->add(ItemBasePeer::ID_CAMPO, $this->id_campo); if (!isset($this->lastItemBaseCriteria) || !$this->lastItemBaseCriteria->equals($criteria)) { $count = ItemBasePeer::doCount($criteria, $con); } else { $count = count($this->collItemBases); } } else { $count = count($this->collItemBases); } } return $count; }