fluentpdo
fluentpdo copied to clipboard
Using PDO::FETCH_COLUMN on fetchAll
I'm not able to use PDO::FETCH_COLUMN like fetchAll in PDO.
It's used to return results in a single dimensional array instead of bi-dimensional array. It's possible to use this?
$query = static::getInstance()->from('products')
->select(NULL)
->select('price');
return $query->fetchAll();
It's returning something like this:
array(4) {
[0]=>
array(1) {
["price"]=>
string(5) "31.00"
}
[1]=>
array(1) {
["price"]=>
string(5) "79.00"
}
[2]=>
array(1) {
["price"]=>
string(5) "62.00"
}
[3]=>
array(1) {
["price"]=>
string(5) "15.00"
}
}
There's any way to return a one-dimensional array?
$stmt = $query->execute();
$this->items = $stmt->fetchAll(\PDO::FETCH_COLUMN);