Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to fetching Column Names from Oracle using PHP

782988Jul 4 2010 — edited Jul 7 2010
I am a novice with PHP and trying to plearn more........I need to fetch column names from oracle and display the column name as a header for result column. Query below does everything as expected but will not fetch column name. Is there are way to fetch column names from oracle

PHP 5.2 using OCI8

Any help is greately appreciated.


<?php
$co = oci_connect('user', 'pass', '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST= ConnectionStringRemoved)(PORT=1521))
(CONNECT_DATA=(SERVER=DEDICATED) (SERVICE_NAME = ordb)))');

$st = oci_parse($conn, "Select ID, TNAME From SCH.TESTTABLE");
echo $st;
oci_execute($st);

echo "<table border='1'>\n";
while ($row = oci_fetch_array($st, OCI_ASSOC+OCI_RETURN_NULLS)) {
echo "<tr>\n";
foreach ($row as $item) {
echo " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;") . "</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";

?>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 4 2010
Added on Jul 4 2010
1 comment
7,629 views