Doc #77373 [Opn->Nab]: The "bind_param" is called too early in examples, the variable is undefined
| From: | requinix@php.net | Date: | Sun, 30 Dec 2018 10:11:58 +0000 |
| Subject: | Doc #77373 [Opn->Nab]: The "bind_param" is called too early in examples, the variable is undefined | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-16256@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77373&edit=1
ID: 77373
Updated by: requinix@php.net
Reported by: buughost+php at gmail dot com
Summary: The "bind_param" is called too early in examples,
the variable is undefined
-Status: Open
+Status: Not a bug
Type: Documentation Problem
Package: Documentation problem
Operating System: WIN10
PHP Version: 7.3.0
Block user comment: N
Private report: N
New Comment:
No, the code is correct. bind_param takes variables by-reference which means they do not have to
exist at the time the method is called. The query will use the values of the variables at the time
execute() is called.
Previous Comments:
------------------------------------------------------------------------
[2018-12-30 10:08:33] buughost+php at gmail dot com
Description:
------------
---
From manual page: https://php.net/mysqli-stmt.get-result
---
In both examples:
// Not a variable : $continent
$stmt->bind_param("s", $continent);
$continent_array = array('Europe','Africa','Asia','North
America');
// Here it is:
foreach($continent_array as $continent)
$stmt->execute(); // Just executing the same query multiple times
$result = $stmt->get_result();
while ($row = $result->fetch_array(MYSQLI_NUM))
{
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77373&edit=1