note 3895 deleted from MySQL functions by danbeck

From: Date: Thu, 07 Sep 2000 14:30:10 +0000
Subject: note 3895 deleted from MySQL functions by danbeck
Groups: php.notes 
Request: Send a blank email to php-notes+get-4332@lists.php.net to get a copy of this message
The following function expands out an SQL query in much the same way as <PRE> $dbh->do("query",{},@param); </PRE> does in the Perl DBI. An example call to the following function is: <PRE> $result = wrap_query( 'select ID from POSITION where name = ? and pass = password(?)', array( $username , $password ) ); </PRE> So here is the function <PRE> function wrap_query( $query, $args ) { $array = explode( '?', $query ); $result = $array[0]; for($i=1; $i<sizeof($array); $i++) { $result.="'".AddSlashes($args[$i-1])."' $array[$i]"; } $result = mysql_query($result); } </PRE>

« previous php.notes (#4332) next »