Modification requete d'enregistrement

This commit is contained in:
Michael RICOIS 2014-10-14 14:28:25 +00:00
parent efeba56cf9
commit a55032de17

View File

@ -116,22 +116,19 @@ class Saisie extends Scores_Ws_Server
);
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$isUpdated = $db->update('jo.infos_entrep', $tabUpdate, "siren=$siren");
if ($isUpdated == 0)
{
$sql = $db->select()->from('infos_entrep', array('siren'), 'jo')->where('siren=?',$siren);
$result = $db->fetchRow($sql);
if (count($result) == 0 ) {
try {
$isInserted = $db->insert('jo.infos_entrep', array_merge(array('siren'=>$siren), $tabUpdate));
} catch(Zend_Db_Exception $e) {
//file_put_contents('test.log', "INSERT = ".$e->getMessage());
file_put_contents('insert.log', "INSERT = ".$e->getMessage());
}
if ($isInserted == 0)
{
$error->errnum = 1;
$error->errmsg = 'Mise a jour impossible';
$output = new SetInfosEntrepReturn();
$output->error = $error;
$output->result = $result;
return $output;
} else {
try {
$isUpdated = $db->update('jo.infos_entrep', $tabUpdate, "siren=$siren");
} catch(Zend_Db_Exception $e) {
file_put_contents('update.log', "INSERT = ".$e->getMessage());
}
}
// Fin mise à jour identité