From: Greg Burri Date: Wed, 16 Sep 2009 16:38:20 +0000 (+0200) Subject: ADD Un début d'helper pour mysql X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=7356c3443f39799adef2f8c803fb44509068c92f;p=cl7.git ADD Un début d'helper pour mysql --- diff --git a/php/mysql_tools.php b/php/mysql_tools.php index 918d6a9..9c1e1c7 100644 --- a/php/mysql_tools.php +++ b/php/mysql_tools.php @@ -2,14 +2,19 @@ # voir : http://us2.php.net/manual/en/function.func-num-args.php -function query($query, $a, $b, $c, $d, $e) +# utiliser mysqli à la place : +# $stmt = $mysqli->prepare("INSERT INTO CountryLanguage VALUES (?, ?, ?, ?)"); +# $stmt->bind_param('sssd', $code, $language, $official, $percent); +function query($query) { - if ($a == null) - return mysql_query($query); - if ($b == null) - return mysql_query(sprintf($query, - is_string($a) ? mysql_real_escape_string($a) : $a - )); + $args = func_get_args(); + foreach ($args as $i => $arg) + if (is_string($arg)) + $args[$i] = mysql_real_escape_string($a); + + array_shift($query, $args); + + return mysql_query(call_user_func_array('sprintf', $args)); } ?> \ No newline at end of file diff --git a/php/pages/inscription.php b/php/pages/inscription.php index cfdd1e7..8f1ad1c 100644 --- a/php/pages/inscription.php +++ b/php/pages/inscription.php @@ -93,7 +93,7 @@ else - email (non-public) + email (non-public, sauf si piratage de la base ^-^´)