pdoでdbに接続してcolumnを取得 – php

<?php  

try 
{
$pdo = new PDO(
'mysql:host=localhost; dbname=db_name;charset=utf8',
'root',
'password',
array(PDO::ATTR_EMULATE_PREPARES => false));
} 


//err
catch (PDOException $e)
{
exit('fald。'.$e->getMessage());
echo 'db_conecct_fald。';
}



$dbname = $pdo->query('SELECT name from table_name;');



while ($row = $dbname->fetch())
{
   echo $row['column_name'];
    echo "<br />";
}

?>