note 115028 deleted from mysqli-stmt.bind-param by cmb

From: Date: Sun, 22 Sep 2019 08:06:32 +0000
Subject: note 115028 deleted from mysqli-stmt.bind-param by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212315@lists.php.net to get a copy of this message
Note Submitter: jmdoren at ok dot cl ---- 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!

« previous php.notes (#212315) next »