Unable to execute fetch(PDO::FETCH_ASSOC) and not updating csv file.

Posted by Rachel on Stack Overflow See other posts from Stack Overflow or by Rachel
Published on 2010-03-25T22:01:26Z Indexed on 2010/03/25 22:03 UTC
Read the original article Hit count: 305

Filed under:
|
// First, prepare the statement, using placeholders
$query = "SELECT * FROM tableName";
$stmt = $this->connection->prepare($query);

// Execute the statement
$stmt->execute();
var_dump($stmt->fetch(PDO::FETCH_ASSOC));

while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) 
{
echo "Hi";
// Export every row to a file
fputcsv($data, $row);
}

Is this correct way to do and if yes than why do I get false value for var_dump and than it does not go into while loop and does not write into csv file.

Any suggestions ?

© Stack Overflow or respective owner

Related posts about php

Related posts about csv