예제 #1
0
 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();
         }
     }
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Agendatelefonicadades $value A Agendatelefonicadades object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Agendatelefonicadades $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getAgendatelefonicadadesid();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }