note 120849 added to mysqli-stmt.bind-param

From: Date: Wed, 22 Mar 2017 04:09:38 +0000
Subject: note 120849 added to mysqli-stmt.bind-param
Groups: php.notes 
Request: Send a blank email to php-notes+get-208940@lists.php.net to get a copy of this message
Instead of reflection or complicated ref assigning do this: <? mysqli_stmt_bind_param($stmt, ...$params); //(Only works in php 5.6+) //Example: //$mysql is from mysqli_connect() //$sql is the query //$types is the type string eg 'ii' //$params is an array of params function execute($mysqli, $sql, $types, $params) { $stmt = mysqli_prepare($mysqli, $sql); mysqli_stmt_bind_param($stmt, $types, ...$params); mysqli_stmt_execute($stmt); return mysqli_stmt_get_result($stmt); } ?> You can have the types as the first element of the array as in the first example, or as a separate variable as in the second example. ---- Server IP: 72.52.91.14 Probable Submitter: 2601:547:500:4c15:22cf:30ff:fe05:22e8 ---- Manual Page -- http://php.net/manual/en/mysqli-stmt.bind-param.php Edit -- https://master.php.net/note/edit/120849 Del: integrated -- https://master.php.net/note/delete/120849/integrated Del: useless -- https://master.php.net/note/delete/120849/useless Del: bad code -- https://master.php.net/note/delete/120849/bad+code Del: spam -- https://master.php.net/note/delete/120849/spam Del: non-english -- https://master.php.net/note/delete/120849/non-english Del: in docs -- https://master.php.net/note/delete/120849/in+docs Del: other reasons-- https://master.php.net/note/delete/120849 Reject -- https://master.php.net/note/reject/120849 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#208940) next »