ctx2002 wrote: > Hi all: > > We are use PHP PDO's Prepared statement to send SQL query to Mysql server. > According to PHP PDO doc, Prepared statement are fast for executing multiple > SQL queries with same parameters. "by using prepared statement you avoid > repeating the analyze/compile/optimize cycle" > > Our application is a web application, each request will have a new Prepared > statement handler generated by PDO Lib. so prepared statement actually > slower than non-prepared statement. > > I just want to know how can we cache Prepared statement handler, So we can > re use it in later http request. > > for example: > > we have a query to pull out all product information from mysql db, each > query just has a different product id , all other parts are same. The query is the same. It works out to be: select * from products where id='X'; So you can just do something like this: $product_query = $dbh->prepare('SELECT * from products where id=?'); $ids = array(1,2,3,4,5); foreach ($ids as $product_id) { $product_query->execute(array($product_id)); $product_details = $product_query->FetchAll(); print_r($product_details); } -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php