Inter Base - PHP

InterBase is a full-featured database that spent much of its life as closed-source and proprietary. In January 2000, Inprise released InterBase under an open source license, allowing everyone access to the source code. InterBase is the first opensource database to be compliant with the SQL 92 standard. Under commercial development for more than 16 years, InterBase compares favorably to Oracle, Sybase, and IBM's DB2. This section discusses the PHP functions for communicating with InterBase, but a tutorial on InterBase itself is out of scope. Apart from the extensive documentation on the InterBase, you may find useful information in books about Borland's C++ compiler or Delphi.

InterBase support was added to PHP by Jouni Ahto. Later work was done by Andrew Avdeev and Ivo Panacek. At the time of writing, InterBase functions in PHP were not complete, but the recent change in licensing will probably encourage developers. You also have the option of using the ODBC functions.

boolean ibase_blob_add(integer blob, string data)
The ibase_blob_add function adds data to a blob. You must create the blob first with ibase_blob_create.

boolean ibase_blob_cancel(integer blob)
Use ibase_blob_cancel to discard a blob you have created with ibase_blob_create.

boolean ibase_blob_close(integer blob)
The ibase_blob_close function writes changes made to a blob to the database.

integer ibase_blob_create(integer link)
The ibase_blob_create function creates a new blob. The link argument is optional and will default to the last-opened connection. A blob identifier is returned.

boolean ibase_blob_echo(string blob)
The ibase_blob_echo function prints the contents of the named blob to the browser.

string ibase_blob_get(integer blob, integer bytes)
Use ibase_blob_get to get the specified number of bytes from a blob.

integer ibase_blob_import(integer file) integer ibase_blob_import(integer link, integer file)
The ibase_blob_import function creates a blob and places the contents of an open file into it. The file argument must be a file identifier as returned by fopen. You may call ibase_blob_import with or without an open link. The file is closed after the import. The blob identifier is returned.

object ibase_blob_info(string blob)
Use ibase_blob_info to get information about a blob. An object is returned with the following properties: isnull, length, maxseg, numseg, stream.

integer ibase_blob_open(string blob)
Use ibase_blob_open to get a blob identifier for an existing blob.

boolean ibase_close(integer link)
Use ibase_close to close a connection created by ibase_connect. If a link is not specified, the last opened link will be closed. The default transaction will be committed, and other transactions will be rolled back.

boolean ibase_commit(integer link)
The ibase_commit function commits the default transaction on the specified link, or thes last link if none is specified.

integer ibase_connect(string path, string user, string password)
Use ibase_connect to connect to an InterBase database. You must specify a path to database file. The user and password arguments may be omitted. They default to those set in php.ini using the ibase.default_user and ibase.default_password directives.

A connection identifier is returned that is used by most of the other functions in this section. When the script ends, the connection will be closed for you, but you can close it manually with ibase_close. A second connection attempt to the same database as the same user will return the same connection identifier.

Compare this function to ibase_pconnect.

string ibase_errmsg()
Use ibase_errmsg to get the last error message. FALSE is returned when no error message is available.

integer ibase_execute(integer query, value bind, ...)
Use ibase_excute to execute a query prepared with ibase_prepare. If the query contained ? placeholders, you must supply matching bind values following the query identifier. A result identifier is returned if executing a select query.

object ibase_fetch_object(integer result, integer blob)
The ibase_fetch_object function returns an object that contains a property for each column in the next result row. The name of the property will match the name of the column. The blob argument is optional. If set to IBASE_TEXT, blob columns will be returned as text. Otherwise the blob identifier is returned. FALSE is returned when no rows remain.

array ibase_fetch_row(integer result, integer blob)
The ibase_fetch_row function operates identically to ibase_fetch_object except that an array is returned. Instead of being referenced by name, columns are referenced by number, starting with 0.

array ibase_field_info(integer result, integer field)
Use ibase_field_info to get information about a column in a result set. An associative array is returned containing the following elements: alias, length, name, relation, type.

boolean ibase_free_query(integer query)
Use ibase_free_query to free memory associated with a prepared query.

boolean ibase_free_result(integer result)
Use ibase_free_result to free memory associated with a result set.

integer ibase_num_fields(integer result)
The ibase_num_fields function returns the number of fields in a result set.

ibase_pconnect(string path, string user, string password, string character_set)
The ibase_pconnect function works similarly to ibase_connect. The difference is that connections are not closed by PHP or by your script. They persist with the server process to be reused when later script executions need identical connections.

integer ibase_prepare(string query) integer ibase_prepare(integer link, string query)
Use ibase_prepare to prepare a query for later execution with ibase_execute. If you leave out the link argument, the last-opened link will be used. A query identifier is returned.

integer ibase_query(string query, value bind, ...) integer ibase_query(integer link, string query, value bind, ...)
The ibase_query function executes a query on an open connection. You may skip the link identifier, causing the last-opened connection to be used. If the query contains ? placeholders, you must match them with bind values that follow the query argument. A result identifier is returned. It is used with functions such as ibase_fetch_row.

//connect to database
if(!($dbLink = ibase_connect("mydatabase.gdb", "leon", "secret"))
print("Unable to connect!<BR>n");
//begin transaction
$dbTran = ibase_trans(IBASE_DEFAULT, $dbLink);
//insert a message using bind parameters
$Query = "INSERT INTO message " .
"VALUES (?, ?, ?) ";
if(!($result = ibase_query($dbLink, $Query, $inputID, $inputTitle,
print("Unable to insert row!<BR>n");
//release memory
//dump table
print("<TABLE BORDER="1">n");
$Query = "SELECT * FROM message ";
if(!($result = ibase_query($dbLink, $Query))
print("Unable to query table!<BR>n");
//print headers
for($i=0; $i<ibase_num_fields($result); $i++)
$info = ibase_field_info($result, $i);
//get all rows
while($row = ibase_fetch_row($result))
for($i=0; $iibase_num_fields($result); $i++)
//release memory
//commit transaction
//close connection

boolean ibase_rollback(integer link)
The ibase_rollback function causes a transaction to roll back. The default transaction on the specified link is rolled back. The last link will be used if none is specified.

boolean ibase_timefmt(string format)
Use ibase_timefmt to set the format for datetime columns. The format string should follow the rules of strftime. The default format is "%m/%d/%Y %H:%M:%S".

integer ibase_trans(integer flags, integer link)
The ibase_trans function returns a transaction identifier. The flags can be any combination of the constants. Use | to combine them. IBASE_DEFAULT matches InterBase read, write, snapshot, and wait properties. The link argument is optional. The last connection established will be used if it's left out.


All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

PHP Topics