FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » mysqli_stmt::store_result?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
mysqli_stmt::store_result? [message #174224] Fri, 27 May 2011 16:20 Go to previous message
David is currently offline  David
Messages: 2
Registered: December 2010
Karma:
Junior Member
Hmm.. My attempt to run two mysqli prepared statements (SELECT queries), one
immediately after the other, failed with the error:

"mysqli::prepare() [function.mysqli-prepare]: All data must be fetched
before a new statement prepare takes place"


Searching for clues about this error message eventually led me to
mysqli_stmt::store_result, but what does this function actually *do*?
(The description in the manual is somewhat terse to say the least..)

http://www.php.net/manual/en/mysqli-stmt.store-result.php


I'd been using "ext/mysqli: Part I - Overview and Prepared Statements" as my
guide to using prepared statements, and mysqli_stmt::store_result doesn't
seem to feature in the examples there at all? (!)

http://devzone.zend.com/article/686


My code was along the lines of:

// $dbh is my DB handle..
$stmt = $dbh->prepare("
SELECT
some data..
WHERE
some conditions.. = ?
");

$stmt->bind_param('i..', some values from variables..);

$stmt->execute();

$stmt->bind_result(
some variables corresponding to the selected data..
);


$stmt2 = $dbh->prepare("
etc...

At this point I now wanted to 'prepare' my next query ($stmt2) so that I'd
have all of the data I needed, and could then (I thought) worry about
actually fetching the data from these result sets, and processing that data,
at a later point in my code.

But not so, obviously my understanding is wrong..

So, at which point in the sequence of commands does the result set actually
get extracted from the database for PHP to deal with? I had assumed that
that was what 'execute' did: then (somewhat at your leisure) 'bind_result'
matched up the field names in the result set with your desired variable
names, and then finally 'fetch' grabbed the next row from the result set..?

But it's looking as though 'store_result' may be what actually produces the
result set? But this command was missing from the tutorial on the Zend
website, and my previous code had been working fine without it.. I'm
thoroughly confused!

If anybody can offer any advice to aid my understanding, I'd be very grateful!

Thanks,


David.
[Message index]
 
Read Message
Read Message
Previous Topic: looking for ideas on how turn a php created html table with 10 rows into a 2 row table with extra columns appended to the end
Next Topic: Persistence engine for GWT
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 01:53:51 GMT 2024

Total time taken to generate the page: 0.04192 seconds