Results 1 to 3 of 3

Thread: [RESOLVED] Does a prepared statement get cached?

  1. #1
    Join Date
    Dec 2006

    resolved [RESOLVED] Does a prepared statement get cached?

    Hey everyone, quick question. Says the PHP manual,
    $stmt = $mysqli->prepare("SELECT * FROM test WHERE id = ?");
    this will make the database prepare itself to run this query; find out the best way to run it, how to structure the results, etc. If I use this same $stmt later, then all that work is still saved, yay!

    My question, however, is what if I don't use the $stmt variable? If I call $mysql->prepare with the same exact string, will it see that its the same as before, and use the earlier preparations? Or do I absolutely have to save the $stmt variable and use it again, to get the nice speed boost?

    - Evan

  2. #2
    Join Date
    Aug 2004
    As far as I know, a new "prepare" would be handled separately and without knowledge of the prior query. I cannot claim to be 100% positive about that, but pretty darned close.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Dec 2006
    Okay cool, thanks for the quick response.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center