note 63485 added to function.mysql-query

From: Date: Wed, 22 Mar 2006 20:49:25 +0000
Subject: note 63485 added to function.mysql-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-106371@lists.php.net to get a copy of this message
<?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)); } ?> ---- Server IP: 212.47.220.12 Probable Submitter: 193.40.133.134 (proxied: 193.40.10.178) ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-query.php Edit -- http://master.php.net/note/edit/63485 Del: integrated -- http://master.php.net/note/delete/63485/integrated Del: useless -- http://master.php.net/note/delete/63485/useless Del: bad code -- http://master.php.net/note/delete/63485/bad+code Del: spam -- http://master.php.net/note/delete/63485/spam Del: non-english -- http://master.php.net/note/delete/63485/non-english Del: in docs -- http://master.php.net/note/delete/63485/in+docs Del: other reasons-- http://master.php.net/note/delete/63485 Reject -- http://master.php.net/note/reject/63485 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#106371) next »