note 42931 deleted from ref.ibase by thiago

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: chrisg at cordell dot com dot au 

----

Simple function to retrieve the results of an SQL statement into an array, will also cater for BLOB fields:

function interbase_sql_exec ($sql) {
   $dataArr = array();
   $host = "svrname:path\filename.GDB";
   $username = "whatever";
   $password = "******";
   $connection = ibase_connect ($host, $username, $password,'ISO8859_1', '100', '1');
   $rid = @ibase_query ($connection, $sql);
   if ($rid===false) errorHandle(ibase_errmsg(),$sql);
   $coln = ibase_num_fields($rid);
   $blobFields = array();
   for ($i=0; $i < $coln; $i++) {
       $col_info = ibase_field_info($rid, $i);
       if ($col_info["type"]=="BLOB") $blobFields[$i] = $col_info["name"];
   }
   while ($row = ibase_fetch_row ($rid)) {
       foreach ($blobFields as $field_num=>$field_name) {
           $blobid = ibase_blob_open($row[$field_num]);
           $row[$field_num] = ibase_blob_get($blobid,102400);
           ibase_blob_close($blobid);
       }
       $dataArr[] = $row;
   }
   ibase_close ($connection);
   return $dataArr;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.