$result = $stmt->execute();

foreach ($result as $value) {
     echo var_dump($value);
}

The problem is instead using foreach I want to use something like
fetchAll(PDO::FETCH_COLUMN). I guess it's not possible with
Zend\Db\Adapter\Driver\ResultInterface? Any suggestions?

The ResultInterface is there primarily to provide an interface that Zend\Db\ResultSet\ResultSet can utilize. You need to foreach over results as it is the only sure way to be able to get information out of a database (per platform, you can't be sure what kind of cursor the database implements).

Beyond that, once you get a logical row, the row is expected to be in associative array form:

foreach ($result as $row) {
    $row['actual_column_name'];
}

They should be ordered by their ordinal position in the database (if using * in your select, or in the order specified in your SELECT clause.)

In either case, you can always:

$value = array_values($row); // to get rid of column names
$value[0] // to retrieve the first column, for example.

This is even easier in PHP 5.4:

$column0 = array_values($row)[0];

-ralph


--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to