[phplib] metadata with Oracle ? From: nemholt_jf <email protected>
Date: 06/11/01

Hi!

I have a PHP script that take a SQL query as input and generate PNG
graphics as output. I do this by executing the query without looking at it,
but instead handle the data returned using the metadata and by having the
data transferred to an array.
I then use the metadata to get table & column names and types.

With MySQL I do something like what is listed below, but with Oracle I
cannot access the metadata unless I specify the table I selected from, and
I don't know if it'll even work if I select from more than one table.
Since I don't want to try breaking the SQL staments apart (they're dynamic
so it's not straight forward), I'd like to mirror the MySQL functionality
in Oracle.

Has anyone tried adding the functionality I have in MySQL (the database
returns metadata related to the last query) to Oracle ?

A example :

$query = stripslashes($HTTP_GET_VARS["query"]);

$db->query($query) or $logfile->log("Error : db->query()");

/* Get table/database metadata. */
$metadata = $db->metadata() or $logfile->log("Error : db->metadata()");

$query_result = array();

$query_result_fields = $db->num_fields() or $logfile->log("Error : db->num_fields()");
$query_result_rows = $db->nf() or $logfile->log("Error : db->nf()");

while ($db->next_record())
{
     $row = array();
     for ($counter = 0; $counter < $query_result_fields; $counter++)
     {
          array_push($row, $db->f($counter));
          if ($counter > 0)
          {
               if ($db->f($counter) > $query_result_max)
               {
                    $query_result_max = $db->f($counter);
               }
          }
     }
     array_push($query_result, $row);
}

/Jesper

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>