Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Excerpt

PDO provides a method to get database field name (column name) from the query result.


Below and below code shows the example:

Code Block
languagephp
$p = new PDO( "mysql:host=localhost;dbname=foo;charset=utf8", "chun", "kang");
$select = $p->query("select * from test_table");
$fieldname = $select->fetch(PDO::FETCH_ASSOC);

...