php - PDO multiple queries -


as of php version 5.3 pdo_mysql driver has been repleaced in favour of pdo_mysqlnd. introduced support multiple queries.

though, can't figure out how both result sets if more 1 select query has been passed. both queries have been executed, can't second 1 dumped.

$db->query("select 1; select 2;")->fetchall(pdo::fetch_assoc); 

returns:

array(1) {   [0]=>   array(1) {     [1]=>     string(1) "1"   } } 

it turns out need use pdostatement::nextrowset.

$stmt   = $db->query("select 1; select 2;"); $stmt->nextrowset(); var_dump( $stmt->fetchall(pdo::fetch_assoc) ); 

this return result second query.

it bit odd implementation. easier if multi-query statement return both results sets under 1 array. however, advantage implementation allows fetch every query using different fetch styles.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -