What is the prepare usage of pdo?

Source: Internet
Author: User
I would like to ask about the pdo prepare statement, which was edited by Cainiao at 2013-03-0816: 13: 15 after being edited by rainxies. this method is similar to querying multiple SQL statements at the same time, how to obtain the result set using prepare? $ Dbh & nbsp ;=& nbsp; new & nbs ask about pdo prepare usage
At last, this post was edited by rainxies at 16:13:15 on,
Similar to this method, you can query multiple SQL statements at the same time. how can you obtain the result set using prepare?

$dbh = new PDO($dbConnString, $dbInfo['username'], $dbInfo['password']);
$query = $dbh->query($queryString);
$i = 0;
foreach ($query as $query2) {
  $queryReturn[$i] = $query2;
  $i++;
}


------ Solution --------------------
This post was last edited by xuzuning at 09:05:47. if your SQL command is like #1, sorry!
Select FOUND_ROWS () will not be sent to mysql for execution because it violates the security conventions for executing only one command at a time.

You can write your two commands as a stored procedure.
delimiter //
CREATE PROCEDURE `test`()
begin
  select SQL_CALC_FOUND_ROWS * from table limit 1,10;
  select FOUND_ROWS();
end;
// 
Then execute
$queryString = 'call test();';
$query = $dbh->query($queryString);
do {
  $rows = $query->fetchAll();
  print_r($rows);
}while($query->nextRowset());

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.