diff --git a/library/WsScore/Saisie/v0.2/Saisie.php b/library/WsScore/Saisie/v0.2/Saisie.php index 7b888269..c547b696 100644 --- a/library/WsScore/Saisie/v0.2/Saisie.php +++ b/library/WsScore/Saisie/v0.2/Saisie.php @@ -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é