From 48f0bac7fd58fb65e7a74293551a80db722a4dce Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 6 Aug 2021 13:59:30 +0100 Subject: [PATCH] Updating mysqli: bind_result (#770) --- reference/mysqli/mysqli_stmt/bind-result.xml | 87 ++++++++------------ 1 file changed, 36 insertions(+), 51 deletions(-) diff --git a/reference/mysqli/mysqli_stmt/bind-result.xml b/reference/mysqli/mysqli_stmt/bind-result.xml index b741beefad..bde4d1150c 100644 --- a/reference/mysqli/mysqli_stmt/bind-result.xml +++ b/reference/mysqli/mysqli_stmt/bind-result.xml @@ -30,20 +30,31 @@ MySQL client/server protocol places the data for the bound columns into the specified variables var/vars. + + A column can be bound or rebound at any time, even after a result set has + been partially retrieved. The new binding takes effect the next time + mysqli_stmt_fetch is called. + - Note that all columns must be bound after + All columns must be bound after mysqli_stmt_execute and prior to calling mysqli_stmt_fetch. + + + + Depending on column types bound variables can silently change to the corresponding PHP type. - - A column can be bound or rebound at any time, even after a result set has - been partially retrieved. The new binding takes effect the next time - mysqli_stmt_fetch is called. - + + + This functions is useful for simple results. To retrieve iterable result + set, or fetch each row as an array or object, + use mysqli_stmt_get_result. + + @@ -85,32 +96,21 @@ prepare("SELECT Code, Name FROM Country ORDER BY Name LIMIT 5")) { - $stmt->execute(); +$stmt = $mysqli->prepare("SELECT Code, Name FROM Country ORDER BY Name LIMIT 5"); +$stmt->execute(); - /* bind variables to prepared statement */ - $stmt->bind_result($col1, $col2); +/* bind variables to prepared statement */ +$stmt->bind_result($col1, $col2); - /* fetch values */ - while ($stmt->fetch()) { - printf("%s %s\n", $col1, $col2); - } - - /* close statement */ - $stmt->close(); +/* fetch values */ +while ($stmt->fetch()) { + printf("%s %s\n", $col1, $col2); } -/* close connection */ -$mysqli->close(); - -?> ]]> @@ -119,36 +119,24 @@ $mysqli->close(); ]]> - &examples.outputs; + &examples.outputs.similar; mysqli_stmt_fetch mysqli_prepare mysqli_stmt_prepare - mysqli_stmt_init - mysqli_stmt_errno - mysqli_stmt_error