From b59a27ec5c8e852ebf659d11e35de012cf2ee1b1 Mon Sep 17 00:00:00 2001
From: Lucas Mascaro * @return PDO instance de la connexion a la BDD */
- public static function getConnexion(){
+ if(static::$config == null){ if(static::$config == null){ static::$config = json_decode(file_get_contents(dirname(__FILE__).DIRECTORY_SEPARATOR.'config.json'),true);
- }
+ if(static::$connexion == null){ if(static::$connexion == null){ static::$connexion = new PDO('mysql:host='.static::$config['host'].';dbname='.static::$config['database'], static::$config['login'], static::$config['password']);
- }
+ return static::$connexion; return static::$connexion; }
@@ -230,21 +230,21 @@
/** public static function delNumeric($fetchData, $oneDimension=false){
- // cas où fetch renvoie FALSE
+ if( $fetchData === false ) return false; if( $fetchData === false ) return false; /* [1] 2 dimensions
- ===============================================*/
+ if( !$oneDimension ){ if( !$oneDimension ){
- // on supprime les doublons des entrées (indice numérique)
- for( $i = 0 ; $i < count($fetchData) ; $i++ ) // pour tout les utilisateurs
+ foreach($fetchData[$i] as $col => $val){ // pour toutes les entrées
+ for( $i = 0 ; $i < count($fetchData) ; $i++ ) // pour tout les utilisateurs foreach($fetchData[$i] as $col => $val){ // pour toutes les entrées
-
+ if( !mb_detect_encoding($val, 'UTF-8') ) if( !mb_detect_encoding($val, 'UTF-8') ) $fetchData[$i][$col] = utf8_encode($val);
-
- if( is_int($col) ) // si l'indice est un entier
+ unset( $fetchData[$i][$col] ); // on le supprime
+ if( is_int($col) ) // si l'indice est un entier unset( $fetchData[$i][$col] ); // on le supprime }
@@ -263,7 +263,7 @@
/* [2] 1 dimensions }
-
+ return $fetchData; return $fetchData; }
@@ -291,24 +291,24 @@
public static function checkParam($variable, $dbtype){ /* [1] on vérifie que $dbtype est un String
- =============================================================*/
+ if( !is_string($dbtype) ) return false; if( !is_string($dbtype) ) return false; /* [2] Vérifications
- =============================================================*/
- $checker = true; // contiendra VRAI si la vérification s'avère correcte
- $matches = [];
+ $len = 8;
+ $checker = true; // contiendra VRAI si la vérification s'avère correcte
+ $matches = []; $len = 8;
- //si on a un type scalairexlongueur, on traite
+ if(preg_match_all('/([A-Z][a-z]+)(\d+)/s', $dbtype,$matches)){ if(preg_match_all('/([A-Z][a-z]+)(\d+)/s', $dbtype,$matches)){ $dbtype = $matches[1][0]; $len = $matches[2][0]; } switch($dbtype){
- // [1] 'M' / 'F'
+ case 'Civilite': case 'Civilite': $checker = $checker && is_string($variable) && in_array($variable, ['M','F']); break;
@@ -334,8 +334,8 @@
break;
- case 'Date':
- $checker = $checker && is_string($variable) && ( preg_match('/\d{2}\/\d{2}\/\d{4}/', $variable) || preg_match('/\d{4}-\d{2}-\d{2}/', $variable) || preg_match('/\d{4}\/\d{2}\/\d{2}/', $variable) );
+ break;
+ $checker = $checker && is_string($variable) && ( preg_match('/\d{2}\/\d{2}\/\d{4}/', $variable) || preg_match('/\d{4}-\d{2}-\d{2}/', $variable) || preg_match('/\d{4}\/\d{2}\/\d{2}/', $variable) ); break; case 'Heure':
@@ -348,7 +348,7 @@
$checker = $checker && is_string($variable) && preg_match('/(\d+):(\d+)/is',$variable); /* [3] On retourne le résultat de la vérif
- =============================================================*/
+ return $checker; return $checker; }
@@ -368,7 +368,7 @@
Dead Code
- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 7:56:03 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 8:04:45 UTC 2015.
diff --git a/coverage/dashboard.html b/coverage/dashboard.html index cfccc41..661824a 100755 --- a/coverage/dashboard.html +++ b/coverage/dashboard.html @@ -59,7 +59,6 @@- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 7:56:03 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 8:04:45 UTC 2015.
diff --git a/coverage/repos/StatsRepo.php.html b/coverage/repos/StatsRepo.php.html index 19cafd2..a221471 100755 --- a/coverage/repos/StatsRepo.php.html +++ b/coverage/repos/StatsRepo.php.html @@ -213,7 +213,7 @@ Dead Code- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 7:56:03 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 8:04:45 UTC 2015.
diff --git a/coverage/repos/dashboard.html b/coverage/repos/dashboard.html index ac78bbe..a8142b7 100755 --- a/coverage/repos/dashboard.html +++ b/coverage/repos/dashboard.html @@ -59,7 +59,6 @@ -