示例#1
0
 /**
  * Rende persistenti le modifiche all'anagrafica di uno studente sul db
  * @param Studente $s lo studente considerato
  * @param mysqli_stmt $stmt un prepared statement
  * @return int il numero di righe modificate
  */
 private function salvaStudente(Studente $s, mysqli_stmt $stmt)
 {
     $query = " update studenti set \n                    password = ?,\n                    nome = ?,\n                    cognome = ?,\n                    email = ?,\n                    numero_civico = ?,\n                    citta = ?,\n                    provincia = ?,\n                    matricola = ?,\n                    cap = ?,\n                    via = ?\n                    where studenti.id = ?\n                    ";
     $stmt->prepare($query);
     if (!$stmt) {
         error_log("[salvaStudente] impossibile" . " inizializzare il prepared statement");
         return 0;
     }
     if (!$stmt->bind_param('ssssississi', $s->getPassword(), $s->getNome(), $s->getCognome(), $s->getEmail(), $s->getNumeroCivico(), $s->getCitta(), $s->getProvincia(), $s->getMatricola(), $s->getCap(), $s->getVia(), $s->getId())) {
         error_log("[salvaStudente] impossibile" . " effettuare il binding in input");
         return 0;
     }
     if (!$stmt->execute()) {
         error_log("[caricaIscritti] impossibile" . " eseguire lo statement");
         return 0;
     }
     return $stmt->affected_rows;
 }