Req #70787 [Opn->Csd]: mysqli_stmt::bind_param() needs the “ready” variables only

From: Date: Tue, 28 Sep 2021 16:18:32 +0000
Subject: Req #70787 [Opn->Csd]: mysqli_stmt::bind_param() needs the “ready” variables only
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236903@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70787&edit=1 ID: 70787 Updated by: cmb@php.net Reported by: it_poz at interia dot eu Summary: mysqli_stmt::bind_param() needs the “ready” variables only -Status: Open +Status: Closed Type: Feature/Change Request Package: MySQLi related Operating System: irrelevant PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: As of PHP 8.1.0, you can pass an array of *values* to mysqli_stmt::execute() instead of having to call ::bind_param()[1]. For previous PHP versions, you can use the splat operator: $stmt->bind_param('i', ...[$i + 1]) [1] <https://www.php.net/manual/en/migration81.new-features.php#migration81.new-features.mysqli.bind-in-execute> Previous Comments: ------------------------------------------------------------------------ [2015-10-25 20:48:48] it_poz at interia dot eu Description: ------------ The mysqli_stmt::bind_param() needs the “ready” variables but doesn’t accept the parameters as results – in such cases PHP parser outputs the Fatal error: Uncaught Error: “Cannot pass parameter 2 by reference” Test script: --------------- Example 1 (it works): $stmt->bind_param('i', 1) Example 2 (it doesn’t work and Fatal error is signaled): $stmt->bind_param('i', ($i + 1)) Expected result: ---------------- I would expect this method working with the parameter’s values calculated in real time, not just only with “ready” values. Actual result: -------------- Uncaught Error: Cannot pass parameter 2 by reference - for the code example 2 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70787&edit=1

« previous php.bugs (#236903) next »