Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Ajout & Modif de motsclés (sujets)
- $existing = $this->sujets->getPrimaryKeys();
- $values = array_filter(explode('|', trim($request->getParameter('infolettres[motscles_liste]'))));
- if (!is_array($values)) { $values = array(); }
- $values_pas_effacer = array();
- foreach ($values as $value) {
- $s = Doctrine_Query::create()
- ->from('ProfilSujet')
- ->where('profil_id =?', $this->id)
- ->andWhere("valeur LIKE '".$value."'")
- ->limit(1)
- ->fetchOne();
- if ((is_object($s)) and (strlen($s->id) > 0)) {
- array_push($values_pas_effacer, $s->valeur);
- } else {
- if (strlen($value) > 0) {
- array_push($values_pas_effacer, $value);
- $sujet_nouveau = new ProfilSujet();
- $sujet_nouveau->profil_id = $this->id;
- $sujet_nouveau->valeur = $value;
- $sujet_nouveau->save();
- }
- }
- }
- foreach ($existing as $key => $existe_deja) {
- if (!is_numeric(array_search($value, $values_pas_effacer))) {
- $s = Doctrine_Query::create()
- ->from('ProfilSujet')
- ->where('profil_id =?', $this->id)
- ->andWhere('valeur =?', $value)
- ->execute();
- $s->delete();
- }
- }
Add Comment
Please, Sign In to add comment