How to fetch the whole table at once!

Hello,

This question is regarding working with PHP-Oracle.

To display result of a query we use -
oci_result($statement,‘COLUMN_NAME’) function… to demonstrate the use of this function please see the following snippet -
Let’s suppose we are fetching EMPNO column from EMP table from scott’s schema -


$dbconn=oci_connect('scott','tiger');
$query="select * from emp";
$stmt=oci_parse($dbconn,$query);
oci_execute($stmt);
while (oci_fetch($stmt)) 
{
echo oci_result($stmt,'EMPNO');
}

Now this code displays all rows under EMPNO column… but suppose if I do not know how many columns are there in a table and want to display all columns along with all rows, how will I do that?

Urgent help required please…

Thanks in advanced

Thank you that worked… Now just need to indent it in column and row format!

Maybe PHP: oci_fetch_array - Manual ?

Thank you so much… but could you please make a snippet for me as per the scenario I have put up?
I really am able to understand things better that way :slight_smile:

And thank you once agian :smiley:


while ($row = oci_fetch_array($stmt, OCI_ASSOC)) {
  // for each row, loop through the columns
  foreach($row as $column=>$value) {
    // do whatever you want with the column values
    echo "$column - $value <br />";
  }
}

Hey guido,

Can you help me with the following -

Please eagerly waiting for your reply!

Stuck with my project!