note 107595 added to mysqli-stmt.bind-result
| From: | timchampion dot NOSPAM at gmail dot com | Date: | Mon, 20 Feb 2012 19:29:25 +0000 |
| Subject: | note 107595 added to mysqli-stmt.bind-result | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186240@lists.php.net to get a copy of this message | ||
Just wanted to make sure that all were aware of get_result for those needing the result in array
format.
In the code sample, after execute(), perform a get_result() like this:
<?php
// ... this document's example code:
$stmt->execute();
/* instead of bind_result: */
$result = $stmt->get_result();
/* now you can fetch the results into an array - NICE */
while ($myrow = $result->fetch_assoc()) {
printf("%s %s\n", $myrow['Code'], $myrow['Name']);
}
?>
This is much nicer when you have a dozen or more fields coming back from your query. Hope this
helps. Also, as noted in the comments for get_result, it requires mysqlnd.
----
Server IP: 64.71.164.2
Probable Submitter: 192.43.65.245
----
Manual Page -- http://www.php.net/manual/en/mysqli-stmt.bind-result.php
Edit -- https://master.php.net/note/edit/107595
Del: integrated -- https://master.php.net/note/delete/107595/integrated
Del: useless -- https://master.php.net/note/delete/107595/useless
Del: bad code -- https://master.php.net/note/delete/107595/bad+code
Del: spam -- https://master.php.net/note/delete/107595/spam
Del: non-english -- https://master.php.net/note/delete/107595/non-english
Del: in docs -- https://master.php.net/note/delete/107595/in+docs
Del: other reasons-- https://master.php.net/note/delete/107595
Reject -- https://master.php.net/note/reject/107595
Search -- https://master.php.net/manage/user-notes.php