note 63485 deleted from function.mysql-query by bjori

From: Date: Wed, 22 Mar 2006 20:54:36 +0000
Subject: note 63485 deleted from function.mysql-query by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-106372@lists.php.net to get a copy of this message
Note Submitter: dmitry dot polushkin at gmail dot com Reason: bad code ---- <?php /** * MySQL query placeholder * * @param string $query * @param mixed $args ... * @author modificated by Solid @ 2006 (http://dmitry.info) * @example mysql_pquery("SELECT * FROM table WHERE col1=? AND col2=?", $value1, $value2); * @version 1.0 * @return resource */ function mysql_pquery() { $args = func_get_args(); if(!count($args)) { die('Error: Please define some query in mysql_pquery function.'); } $args[0] = str_replace('%', '%%', $args[0]); if(substr_count($args[0], '?')!=(count($args)-1)) { die('Error: Check your count of arguments in mysql_pquery function.'); } $args[0] = str_replace('?', '%s', $args[0]); for($i=1, $c=count($args); $i<$c; $i++) { if(is_numeric($args[$i])) continue; if(is_array($args[$i])) { die('Error: No arrays can be used in mysql_pquery function.'); } $args[$i] = "'".mysql_real_escape_string($args[$i])."'"; } return mysql_query(call_user_func_array('sprintf', $args)); } ?>

« previous php.notes (#106372) next »