Pieces - setPrivilegesEmail : Doctrine

This commit is contained in:
Michael RICOIS 2016-10-05 10:04:45 +02:00
parent 4b8e58a38e
commit 709e1c8cd6

View File

@ -1141,36 +1141,45 @@ class Pieces extends Scores_Ws_Server
throw new SoapFault('ERR', "Adresse email invalide.");
}
$commandeM = new Application_Model_Sdv1OrderPrivileges();
$sql = $commandeM->select()
->where('login=?', $this->User->login)
->where('refCommande=?', $id);
try {
$result = $commandeM->fetchRow($sql);
} catch (Zend_Db_Exception $e) {
$sql = "SELECT * FROM sdv1.order_privileges WHERE login = :login AND refCommande = :id";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('login', $this->User->login);
$stmt->bindValue('id', $id);
$stmt->execute();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->User->idClient == 1) {
throw new SoapFault('ERR', $e->getMessage());
} else {
}
else {
throw new SoapFault('ERR', "Application error");
}
}
if ( $result !== null ) {
if ($stmt->rowCount() > 0) {
if ( is_int($email) ) {
//Id of secondary email
} else {
}
else {
$dataUpdate = array('email' => $email);
try {
$commandeM->update($dataUpdate, "refCommande='".$id."'");
return true;
} catch (Zend_Db_Exception $e) {
$result = $this->conn->update('sdv1.order_privileges', $dataUpdate,
array('refCommande' => $id));
if ($result) {
return true;
}
}
catch (\Doctrine\DBAL\DBALException $e) {
if ($this->User->idClient == 1) {
throw new SoapFault('ERR', $e->getMessage());
} else {
}
else {
throw new SoapFault('ERR', "Application error");
}
}
}
}
return false;
}