note 115028 added to mysqli-stmt.bind-param
| From: | jmdoren at ok dot cl | Date: | Wed, 14 May 2014 18:37:01 +0000 |
| Subject: | note 115028 added to mysqli-stmt.bind-param | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199537@lists.php.net to get a copy of this message | ||
I just wrote a function to bind a variable number of parameters
function bind_param_array( $stmt, $types, $vars ){
/* ------------------------------------------------------------------------ */
$php_command = '$stmt->bind_param( $types';
for( $i=0;$i<count($vars);$i++)
{
$php_command .= ',$vars['.$i.']';
}
$php_command .= ');';
return eval( $php_command );
}
yo can use it like this
$params = array( "one", "two", "two again" );
$types = str_repeat( 's', count( $params );
$stmt = $MysqliObject->prepare( $query );
bind_param_array( $stmt, $types,$params);
enjoy it!
----
Server IP: 72.52.91.14
Probable Submitter: 190.47.7.100
----
Manual Page -- http://php.net/manual/en/mysqli-stmt.bind-param.php
Edit -- https://master.php.net/note/edit/115028
Del: integrated -- https://master.php.net/note/delete/115028/integrated
Del: useless -- https://master.php.net/note/delete/115028/useless
Del: bad code -- https://master.php.net/note/delete/115028/bad+code
Del: spam -- https://master.php.net/note/delete/115028/spam
Del: non-english -- https://master.php.net/note/delete/115028/non-english
Del: in docs -- https://master.php.net/note/delete/115028/in+docs
Del: other reasons-- https://master.php.net/note/delete/115028
Reject -- https://master.php.net/note/reject/115028
Search -- https://master.php.net/manage/user-notes.php