Приглашаем посетить
Мода (modnaya.ru)

Retrieving Results of a Query to Firebird

Previous
Table of Contents
Next

Retrieving Results of a Query to Firebird

$result = ibase_query();
ibase fetch object($result);


No matter if you are using ibase_query or ibase_execute(), at the end, you have a handle for the resultset, which you can iterate with ibase_fetch_assoc()which returns an associative arrayor ibase_fetch_object()which returns an object. This code uses the latter method.

Keep in mind that Firebird and InterBase return column names in uppercase, so the object properties (and the keys in the associative arrays) are uppercase, too.

Retrieving Data from InterBase/Firebird (ibase_fetch.php; excerpt)
<table>
<tr><th>#</th><th>Quote</th><th>Author</th><th>Year<
  /th></tr>
<?php
  if ($db = ibase_connect('//CHRISTIAN2003/tmp/
    quotes.gdb', 'user', 'password')) {
    $result = ibase_query($db, 'SELECT * FROM
      quotes');
    while ($row = ibase_fetch_object($result)) {
      printf(
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></
   tr>',
        htmlspecialchars($row->ID),
        htmlspecialchars($row->QUOTE),
        htmlspecialchars($row->AUTHOR),
        htmlspecialchars($row->QYEAR)
      );
    }
    ibase_close($db);
  } else {
    echo '<tr><td colspan="4">Connection
      failed.</td></tr>';
  }
?>
</table>


Previous
Table of Contents
Next