Пример #1
0
 /**
  * Inserisce o aggiorna la tabella
  * @param ProPayment_Database $db 
  * @return string Messaggio di creazione / aggiornamento o errore
  */
 public function checkTable($db)
 {
     $this->db = $db;
     if ($this->db->tableExists($this->name)) {
         $updated = false;
         // la tabella esiste: devo verificare i campi e gli indici
         foreach ($this->fields as $name => $def) {
             if (!$this->db->fieldExists($this->name, $name)) {
                 $q = "ALTER TABLE `" . $this->name . "` ADD COLUMN `" . $name . "` " . $def;
                 $result = $this->db->queryExec($q);
                 if (!$result) {
                     return "Errore nell'aggiunta del campo " . $name . " alla tabella " . $this->name . ": " . $this->db->getErrorMsg();
                 }
                 $updated = true;
             }
         }
         foreach ($this->indexes as $name => $def) {
             if (!$this->db->indexExists($this->name, $name)) {
                 $q = "ALTER TABLE `" . $this->name . "` ADD " . $def;
                 $result = $this->db->queryExec($q);
                 if (!$result) {
                     return "Errore nell'aggiunta dell'indice " . $name . " alla tabella " . $this->name . ": " . $this->db->getErrorMsg();
                 }
                 $updated = true;
             }
         }
         if ($updated) {
             return "Tabella aggiornata: " . $this->name;
         } else {
             return "";
         }
     } else {
         // la tabella non esiste: la devo creare
         $q = $this->buildCreateTableQuery();
         $result = $this->db->queryExec($q);
         if ($result) {
             return "Tabella creata: " . $this->name;
         } else {
             return "Errore nella creazione della tabella " . $this->name . ": " . $this->db->getErrorMsg();
         }
     }
 }
Пример #2
0
 /**
  * Contrassegna un record dalla tabella di associazione transazioni come ritornato
  * @param string $idtransazione
  * @return bool TRUE se operazione riuscita, FALSE se non riuscita
  */
 private function returnCustomOrder($idtransazione)
 {
     $q = "UPDATE #__propay_transactions SET returned=1 WHERE idtransazione='" . $this->db->escape($idtransazione) . "'";
     return $this->db->queryExec($q);
 }