MySQL Improved Extension (
Mysqli
)
2443
When
mysqli_stmt_fetch
is called to fetch data, the MySQL client/server protocol places the data
for the bound columns into the specified variables
var1, ...
.
Note
Note that 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.
Parameters
stmt
Procedural style only: A statement identifier returned by
mysqli_stmt_init
.
var1
The variable to be bound.
Return Values
Returns
TRUE
on success or
FALSE
on failure.
Examples
Example 20.153. Object oriented style
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* prepare statement */
if ($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);
/* fetch values */
while ($stmt->fetch()) {
printf("%s %s\n", $col1, $col2);
}
/* close statement */
$stmt->close();
}
/* close connection */
$mysqli->close();
?>
Example 20.154. Procedural style
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* check connection */
if (!$link) {
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...