Fix: remplacement de LIKE dans la requete sql par REGEXP afin de palier au différent format de numérotation

je vais corriger les autres modules de numérotation paramétrable
This commit is contained in:
Regis Houssin 2007-07-19 17:15:04 +00:00
parent 77843fb87d
commit 7d5b36c3d9

View File

@ -175,7 +175,7 @@ function info()
$searchyy=''; $searchyy='';
$sql = "SELECT MAX(ref)"; $sql = "SELECT MAX(ref)";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
if ($conf->global->FICHEINTER_NUM_RESTART_BEGIN_YEAR) $sql.= " WHERE ref like '".$this->searchLast."%'"; if ($conf->global->FICHEINTER_NUM_RESTART_BEGIN_YEAR) $sql.= " WHERE ref REGEXP '^".$this->searchLast."'";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
@ -189,7 +189,7 @@ function info()
$previousyy=''; $previousyy='';
$sql = "SELECT MAX(ref)"; $sql = "SELECT MAX(ref)";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
$sql.= " WHERE ref like '".$this->searchLastWithPreviousYear."%'"; $sql.= " WHERE ref REGEXP '^".$this->searchLastWithPreviousYear."'";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
@ -204,7 +204,7 @@ function info()
// Recherche rapide car restreint par un like sur champ indexé // Recherche rapide car restreint par un like sur champ indexé
$sql = "SELECT MAX(0+SUBSTRING(ref,-".$posindice."))"; $sql = "SELECT MAX(0+SUBSTRING(ref,-".$posindice."))";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
$sql.= " WHERE ref like '${searchyy}%'"; $sql.= " WHERE ref REGEXP '^".$searchyy."'";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
@ -377,9 +377,9 @@ function info()
// On récupère le mois si besoin // On récupère le mois si besoin
$this->mm = strftime("%m",time()); $this->mm = strftime("%m",time());
$this->numMatrice[$k] = '$mm'; $this->numMatrice[$k] = '$mm';
$this->searchLast .= $this->mm; $this->searchLast .= '[0-9][0-9]';
$this->searchLastWithNoYear .= '[0-9][0-9]'; $this->searchLastWithNoYear .= '[0-9][0-9]';
$this->searchLastWithPreviousYear .= $this->mm; $this->searchLastWithPreviousYear .= '[0-9][0-9]';
$k++; $k++;
} }
else if ($idMatrice == 'counter') else if ($idMatrice == 'counter')