My pdo connection is set up to return standard objects, and I can use the traversal interface to iterate over the results as follows:
$stmt=$this->pdo->prepare($sql);
$stmt->execute($arr);
foreach($stmt as $rs) {
//$rs is a stdObject since the pdo connection is set up to return stdObjects
}
Per http://php.net/manual/en/pdo.query.php, I can specify the fetch_style and similarily itterate over the results as follows:
$stmt = $pdo->query($sql, PDO::FETCH_ASSOC);
foreach($stmt as $rs) {
//$rs is an array even though pdo connection is set up to return stdObject since I included `PDO::FETCH_ASSOC`
}
What I want, however, is to use a prepared statement when my pdo connection is set up to return standard objects, and use the traversal interface to iterate over the results and return arrays:
$stmt=$this->pdo->prepare($sql);
$stmt->execute($arr);
foreach($stmt as $rs) {
// pdo connection is set up to return stdObject. What can be done to make $rs an array?
}
How can this be done?
Note that typecasting to an array is not an acceptable answer as not using the traversal interface in the first place would be a better approach.
However, stating that it is not possible (if true) is an acceptable answer.