php - PDO::FETCH_COLUMN fetches nothing -


the following code gives me array $a containing description.

$stmt = $dbh->prepare("select description, id     money_items"); $stmt->execute(); $a = $stmt->fetchall(pdo::fetch_column, 0); $id = $stmt->fetchall(pdo::fetch_column, 1); 

but $id array comes out blank.

   array    (    ) 

if remove $a = $stmt->fetchall(pdo::fetch_column, 0); line, $id array comes out fine. allowed fetch 1 column results?

what looking

$results = $stmt->fetchall(pdo::fetch_assoc);  

this fetch columns , rows array -

http://wiki.hashphp.org/pdo_tutorial_for_mysql_developers

to answer actual question though, guess fetchall function called on statement runs through rows, internal pointer in array @ end when fetch second column.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -