Loading CHANGELOG.md +6 −0 Original line number Diff line number Diff line CHANGELOG ========= 6.2.2 (19/07/2024) ------------------ - Prise en compte des opérateurs <>, >=, <=, >, < et = pour les injections de paramètres - Gestion du NOT NULL et du NOT IN 6.2.1 (13/06/2023) ------------------ Loading src/Service/BddService.php +41 −3 Original line number Diff line number Diff line Loading @@ -100,6 +100,43 @@ class BddService private function injectKeyMakeOpvar(string $opVar, $value): string { $operators = ['<>', '<=', '>=', '>', '<', '=']; foreach( $operators as $operator ){ if (str_starts_with($opVar, $operator)){ break; } } $result = 'AND '.trim(substr( $opVar, strlen($operator))); if (null == $value){ if ('<>' == $operator){ return $result.' IS NOT NULL'; }else{ return $result.' IS NULL'; } } if (is_array($value)){ if ('=' == $operator){ return $result.' IN '.$this->escape($value); } if ('<>' == $operator){ return $result.' NOT IN '.$this->escape($value); } throw new \Exception('On ne peut pas confronter un tableau de données à l\'opérateur "'.$operator.'"'); } $result .= ' '.$operator.' '.$this->escape($value); return $result; } /** * Transforme en filtre les commentaires de variables d'optimisation placés dans une requête * Loading @@ -113,10 +150,11 @@ class BddService while(false !== ($start=strpos($query, '/*@'.$k))){ $end = strpos($query, '*/', $start) + 2; $varStart = $start + strlen($k) + 4; $opVarStart = $start + strlen($k) + 3; $opVar = substr($query, $opVarStart, $end - $opVarStart - 2); $nf = substr($query, $varStart, $end - $varStart - 2); $nf = 'AND '.$nf.self::equals($v); $nf = $this->injectKeyMakeOpvar($opVar, $v); $query = substr_replace($query, $nf, $start, $end - $start); } Loading Loading
CHANGELOG.md +6 −0 Original line number Diff line number Diff line CHANGELOG ========= 6.2.2 (19/07/2024) ------------------ - Prise en compte des opérateurs <>, >=, <=, >, < et = pour les injections de paramètres - Gestion du NOT NULL et du NOT IN 6.2.1 (13/06/2023) ------------------ Loading
src/Service/BddService.php +41 −3 Original line number Diff line number Diff line Loading @@ -100,6 +100,43 @@ class BddService private function injectKeyMakeOpvar(string $opVar, $value): string { $operators = ['<>', '<=', '>=', '>', '<', '=']; foreach( $operators as $operator ){ if (str_starts_with($opVar, $operator)){ break; } } $result = 'AND '.trim(substr( $opVar, strlen($operator))); if (null == $value){ if ('<>' == $operator){ return $result.' IS NOT NULL'; }else{ return $result.' IS NULL'; } } if (is_array($value)){ if ('=' == $operator){ return $result.' IN '.$this->escape($value); } if ('<>' == $operator){ return $result.' NOT IN '.$this->escape($value); } throw new \Exception('On ne peut pas confronter un tableau de données à l\'opérateur "'.$operator.'"'); } $result .= ' '.$operator.' '.$this->escape($value); return $result; } /** * Transforme en filtre les commentaires de variables d'optimisation placés dans une requête * Loading @@ -113,10 +150,11 @@ class BddService while(false !== ($start=strpos($query, '/*@'.$k))){ $end = strpos($query, '*/', $start) + 2; $varStart = $start + strlen($k) + 4; $opVarStart = $start + strlen($k) + 3; $opVar = substr($query, $opVarStart, $end - $opVarStart - 2); $nf = substr($query, $varStart, $end - $varStart - 2); $nf = 'AND '.$nf.self::equals($v); $nf = $this->injectKeyMakeOpvar($opVar, $v); $query = substr_replace($query, $nf, $start, $end - $start); } Loading