note 107568 added to mysqli.prepare
| From: | timchampion dot NOSPAM at gmail dot com | Date: | Fri, 17 Feb 2012 20:56:07 +0000 |
| Subject: | note 107568 added to mysqli.prepare | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186201@lists.php.net to get a copy of this message | ||
Just wanted to make sure that all were aware of get_result.
In the code sample, after execute(), perform a get_result() like this:
<?php
// ... document's example code:
/* bind parameters for markers */
$stmt->bind_param("s", $city);
/* execute query */
$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()) {
// use your $myrow array as you would with any other fetch
printf("%s is in district %s\n", $city, $myrow['district']);
}
?>
This is much nicer when you have a dozen or more fields coming back from your query. Hope this
helps.
----
Server IP: 64.71.164.2
Probable Submitter: 192.43.65.245
----
Manual Page -- http://www.php.net/manual/en/mysqli.prepare.php
Edit -- https://master.php.net/note/edit/107568
Del: integrated -- https://master.php.net/note/delete/107568/integrated
Del: useless -- https://master.php.net/note/delete/107568/useless
Del: bad code -- https://master.php.net/note/delete/107568/bad+code
Del: spam -- https://master.php.net/note/delete/107568/spam
Del: non-english -- https://master.php.net/note/delete/107568/non-english
Del: in docs -- https://master.php.net/note/delete/107568/in+docs
Del: other reasons-- https://master.php.net/note/delete/107568
Reject -- https://master.php.net/note/reject/107568
Search -- https://master.php.net/manage/user-notes.php