public static function update($IDL, $EMAILS) { $RESULTATS['Afegits'] = 0; $RESULTATS['Esborrats'] = 0; $RESULTATS['Erronis'] = 0; $RESULTATS['Existents'] = 0; $EMAILS_NEW = array(); $EMAILS_OLD = nl2br($EMAILS); $EMAILS_OLD = explode('<br />', $EMAILS_OLD); //Treiem els espais en blanc i sals buits. foreach ($EMAILS_OLD as $K => $E) { if (strlen($E) > 3) { $EMAILS_NEW[trim($E)] = trim($E); $RESULTATS['Existents']++; } } //Mirem els que hem d'afegir foreach ($EMAILS_NEW as $E) { $OE = self::retrieveByPK($IDL, $E); if (!$OE instanceof MissatgesEmails) { if (!self::checkEmail($E)) { $RESULTATS['Erronis']++; $RESULTATS['Existents']--; } else { $OE = new MissatgesEmails(); $OE->setIdllista($IDL); $OE->setEmail($E); $OE->save(); $RESULTATS['Afegits']++; $RESULTATS['Existents']--; } } } //Mirem els que hem d'esborrar $C = new Criteria(); $C->add(self::IDLLISTA, $IDL); foreach (self::doSelect($C) as $OE) { if (!in_array($OE->getEmail(), $EMAILS_NEW)) { $OE->delete(); $RESULTATS['Esborrats']++; $RESULTATS['Existents']--; } } return $RESULTATS; }
/** * 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 MissatgesEmails $value A MissatgesEmails object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(MissatgesEmails $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = serialize(array((string) $obj->getIdllista(), (string) $obj->getEmail())); } // if key === null self::$instances[$key] = $obj; } }
/** * 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 MissatgesEmails $value A MissatgesEmails object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(MissatgesEmails $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getIdemail(); } // if key === null self::$instances[$key] = $obj; } }