I wanted to efficiently bind columns and then put everything into one array.
<?php
$columns = array(
'DEVICE_CONFIG' => '',
'CONSUMABLE_INFO' => '',
'DEVICE_UNIQUE_ID' => '',
'STATUS' => '',
'STATUS_MESSAGE' => '',
'LAST_MESSAGE_TIME' => '',
'DEVICE_DESCRIPTION' => ''
);
$statement = $this->connection->prepare($sql);
$statement->execute();
$x = 1;
foreach($columns as $column => $index){
$$column = $index;
eval('$statement->bindColumn(' . $x++ . ', $' . $column . ');');
}
$output= array();
while($statement->fetch(\PDO::FETCH_BOUND)){
$temp = array();
foreach($columns as $columnName => $val){
eval("\$data = \$$columnName;");
$temp[$columnName] = $data;
}
$output[] = $temp;
}
?>