/** * 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 = AgendatelefonicaPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setAgendatelefonicaid($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setNom($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setNif($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setDataalta($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setNotes($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setTags($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setEntitat($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setSiteId($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setActiu($arr[$keys[8]]); } }
static function update($DADES_NOVES, $idA, $idS = 1) { $MERGE = array(); //Carreguem totes les dades de l'agenda $FOA = AgendatelefonicaPeer::initialize($idA, $idS); $DADES_REALS = $FOA->getObject()->getAgendatelefonicadadess(); //Primer esborrem tots els que tenim entrats i guardem les seves dades foreach ($DADES_REALS as $K => $V) { $V->setActiu(false); $V->save(); $MERGE[$V->getAgendatelefonicadadesid()] = $V; } foreach ($DADES_NOVES as $K => $V) { //Si tenim un id > 0 llavors és update. if ($V['id'] > 0) { $MERGE[$V['id']]->setDada($V['Dada']); $MERGE[$V['id']]->setNotes($V['Notes']); $MERGE[$V['id']]->setTipus($V['Select']); $MERGE[$V['id']]->setActiu(true); $MERGE[$V['id']]->save(); //Altrament el donem d'alta } else { $DR = new Agendatelefonicadades(); $DR->setAgendatelefonicaAgendatelefonicaid($idA); $DR->setTipus($V['Select']); $DR->setDada($V['Dada']); $DR->setNotes($V['Notes']); $DR->setSiteId($idS); $DR->save(); } } }
public function executeGAgenda($request) { $this->setLayout('gestio'); $this->IDS = $this->getUser()->getSessionPar('idS'); //Netegem cerca if ($request->getParameter('accio') == 'C') { $this->CERCA = $this->getUser()->setSessionPar('cerca', array('text' => '')); } //Inicialitzem les variables $this->CERCA = $this->getUser()->ParReqSesForm($request, 'cerca', array('text' => "")); $this->accio = $request->getParameter('accio', 'C'); $this->MODE = ""; $this->P = $request->getParameter('P', 1); //Tractem el formulari de cerca $this->FCerca = new CercaForm(); $this->FCerca->bind($this->CERCA); //Definim l'acció segons el botó premut if ($this->getRequest()->hasParameter('BNOU')) { $this->accio = 'N'; } if ($this->getRequest()->hasParameter('BSAVE')) { $this->accio = 'S'; } if ($this->getRequest()->hasParameter('BDELETE')) { $this->accio = 'D'; } if ($this->getRequest()->hasParameter('BCERCA')) { $this->accio = 'L'; } $this->getUser()->setSessionPar('accio', $this->accio); switch ($this->accio) { case 'C': $this->getUser()->addLogAction('inside', 'gAgenda'); $this->AGENDES = AgendatelefonicadadesPeer::doSearch($this->CERCA['text'], $this->IDS, $this->P); break; case 'N': $this->MODE = 'NOU'; $this->FAgenda = AgendatelefonicaPeer::initialize(0, $this->IDS); break; case 'E': $this->MODE = 'EDICIO'; $AID = $request->getParameter('AID'); $this->FAgenda = AgendatelefonicaPeer::initialize($AID, $this->IDS); $OAT = $this->FAgenda->getObject(); $this->DADES = $OAT->getAgendatelefonicadadesActiu(); break; case 'S': $RA = $request->getParameter('agendatelefonica'); $AID = $RA['AgendaTelefonicaID']; $this->FAgenda = AgendatelefonicaPeer::initialize($AID, $this->IDS); $this->FAgenda->bind($RA); if ($this->FAgenda->isValid()) { $this->FAgenda->save(); $this->getUser()->addLogAction($this->accio, 'gAgenda', $this->FAgenda->getObject()); myUser::addLogTimeline('alta', 'agenda', $this->getUser()->getSessionPar('idU'), $this->IDS, $this->FAgenda->getObject()->getAgendatelefonicaId()); $this->AID = $this->FAgenda->getObject()->getAgendatelefonicaid(); AgendatelefonicadadesPeer::update($request->getParameter('Dades'), $this->AID, $this->IDS); //Actualitzem també les dades relacionades $this->MISSATGE = "El registre s'ha modificat correctament."; $this->redirect('gestio/gAgenda?accio=L'); } else { $this->DADES = $this->FAgenda->getObject()->getAgendatelefonicadadess(); $this->MODE = 'EDICIO'; } break; case 'D': $RA = $request->getParameter('agendatelefonica'); $this->AID = $RA['AgendaTelefonicaID']; $this->FAgenda = AgendatelefonicaPeer::initialize($this->AID, $this->IDS); if (!$this->FAgenda->isNew()) { $this->FAgenda->getObject()->setInactiu(); $this->getUser()->addLogAction($this->accio, 'gAgenda', $this->FAgenda->getObject()); myUser::addLogTimeline('baixa', 'agenda', $this->getUser()->getSessionPar('idU'), $this->IDS, $this->FAgenda->getObject()->getAgendatelefonicaId()); } break; default: $this->AGENDES = AgendatelefonicadadesPeer::doSearch($this->CERCA['text'], $this->IDS, $this->P); break; } if (!empty($this->CERCA)) { $this->AGENDES = AgendatelefonicadadesPeer::doSearch($this->CERCA['text'], $this->IDS, $this->P); } else { $this->AGENDES = array(); } }
/** * Get the associated Agendatelefonica object * * @param PropelPDO Optional Connection object. * @return Agendatelefonica The associated Agendatelefonica object. * @throws PropelException */ public function getAgendatelefonica(PropelPDO $con = null) { if ($this->aAgendatelefonica === null && $this->agendatelefonica_agendatelefonicaid !== null) { $this->aAgendatelefonica = AgendatelefonicaPeer::retrieveByPk($this->agendatelefonica_agendatelefonicaid); /* 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->aAgendatelefonica->addAgendatelefonicadadess($this); */ } return $this->aAgendatelefonica; }
/** * 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(AgendatelefonicaPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(AgendatelefonicaPeer::DATABASE_NAME); $criteria->add(AgendatelefonicaPeer::AGENDATELEFONICAID, $pks, Criteria::IN); $objs = AgendatelefonicaPeer::doSelect($criteria, $con); } return $objs; }
/** * Selects a collection of Agendatelefonicadades objects pre-filled with all related objects. * * @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 Agendatelefonicadades objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(self::DATABASE_NAME); } AgendatelefonicadadesPeer::addSelectColumns($criteria); $startcol2 = AgendatelefonicadadesPeer::NUM_COLUMNS - AgendatelefonicadadesPeer::NUM_LAZY_LOAD_COLUMNS; AgendatelefonicaPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + (AgendatelefonicaPeer::NUM_COLUMNS - AgendatelefonicaPeer::NUM_LAZY_LOAD_COLUMNS); $criteria->addJoin(AgendatelefonicadadesPeer::AGENDATELEFONICA_AGENDATELEFONICAID, AgendatelefonicaPeer::AGENDATELEFONICAID, $join_behavior); // symfony_behaviors behavior foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) { call_user_func($sf_hook, 'BaseAgendatelefonicadadesPeer', $criteria, $con); } $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = AgendatelefonicadadesPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = AgendatelefonicadadesPeer::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 = AgendatelefonicadadesPeer::getOMClass(false); $obj1 = new $cls(); $obj1->hydrate($row); AgendatelefonicadadesPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Agendatelefonica rows $key2 = AgendatelefonicaPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = AgendatelefonicaPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = AgendatelefonicaPeer::getOMClass(false); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); AgendatelefonicaPeer::addInstanceToPool($obj2, $key2); } // if obj2 loaded // Add the $obj1 (Agendatelefonicadades) to the collection in $obj2 (Agendatelefonica) $obj2->addAgendatelefonicadades($obj1); } // if joined row not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
<?php if (empty($AGENDES)) { echo '<TR><TD class="LINIA" colspan="3">No s\'ha trobat cap resultat d\'entre ' . AgendatelefonicaPeer::getLinies($IDS) . ' disponibles.</TD></TR>'; } else { $i = 0; foreach ($AGENDES as $A) { $SPAN = '<SPAN>'; foreach ($A->getAgendatelefonicadadesActiu() as $ATD) { $SPAN .= AgendatelefonicadadesPeer::getTipus($ATD->getTipus()) . ': ' . $ATD->getDada() . ' - ' . $ATD->getNotes() . '<BR />'; } $SPAN .= '</SPAN>'; $PAR = ParImpar($i++); echo '<TR> <TD class="' . $PAR . '"><a href="' . url_for('gestio/gAgenda?accio=E&AID=' . $A->getAgendatelefonicaid()) . '" class="tt2" >' . image_tag('template/doc_text_image.png') . $SPAN . '</TD> <TD class="' . $PAR . '"><a href="' . url_for('gestio/gAgenda?accio=E&AID=' . $A->getAgendatelefonicaid()) . '" class="tt2" >' . $A->getNom() . $SPAN . '</TD> <TD class="' . $PAR . '">' . $A->getEntitat() . '</TD> <TD class="' . $PAR . '">' . $A->getTags() . '<TD> </TR>'; } } /* function ParImpar($i) { if($i % 2 == 0) return "PAR"; else return "IPAR"; } */