In MySQL I have the following table:
|type_id | type_name |
--------------------------
|1 | John Doe |
|2 | Peter Griffin |
|3 | Max Wilcox |
My PHP Code looks like this:
$stmt = $dbh->prepare ( "SELECT $column FROM $table" );
$stmt->execute ();
return $stmt->fetchAll ( PDO::FETCH_ASSOC );
This is the result of the return statement:
Array
(
[0] => Array
(
[type_name] => John Doe
)
[1] => Array
(
[type_name] => Peter Griffin
)
[2] => Array
(
[type_name] => Max Wilcox
)
)
Is there a way to get the following output in a direct way?
Array
(
[0] => John Doe
[1] => Peter Griffin
[2] => Max Wilcox
)
At the moment I am converting a two-dimensional array into a one-dimensional array, but this is quite inefficient. If I use PDO::FETCH_NUM the result looks quite similar but instead of "type_name" I always get "0". Maybe someone can help me to modify my PHP statement? Thanks in advance.
return $stmt->fetchAll ( PDO::FETCH_ASSOC );