InterBase functions
InterBase
InterBase is a popular database put out by Borland/Inprise. More
information about InterBase is available at &url.ibase;. Oh, by the way, InterBase
just joined the open source movement!
Full support for InterBase 6 was added in PHP 4.0.
ibase_connect
Open a connection to an InterBase database
Description
int ibase_connect
string database
string
username
string
password
string
charset
int
buffers
int
dialect
string
role
Establishes a connection to an InterBase server.
The database argument
has to be a valid path to database file on the server it resides on.
If the server is not local, it must be prefixed with either
'hostname:' (TCP/IP), '//hostname/' (NetBEUI) or 'hostname@' (IPX/SPX),
depending on the connection protocol used. username
and password can also
be specified with PHP configuration directives ibase.default_user and
ibase.default_password. charset is the default
character set for a database. buffers is the number
of database buffers to allocate for the server-side cache. If 0 or omitted,
server chooses its own default. dialect selects
the default SQL dialect for any statement executed within a connection,
and it defaults to the highest one supported by client libraries.
In case a second call is made to
ibase_connect with the same arguments, no new link
will be established, but instead, the link identifier of the already opened
link will be returned. The link to the server will be closed as soon as the
execution of the script ends, unless it's closed earlier by explicitly calling
ibase_close.
Ibase_connect example
<?php
$dbh = ibase_connect ($host, $username, $password);
$stmt = 'SELECT * FROM tblname';
$sth = ibase_query ($dbh, $stmt);
while ($row = ibase_fetch_object ($sth)) {
print $row->email . "\n";
}
ibase_close ($dbh);
?>
buffers was added in PHP4-RC2.
dialect was added in PHP4-RC2. It is functional
only with InterBase 6 and versions higher than that.
role was added in PHP4-RC2. It is functional
only with InterBase 5 and versions higher than that.
See also: ibase_pconnect.
ibase_pconnect
Creates an persistent connection to an InterBase database
Description
int ibase_connect
string database
string
username
string
password
string
charset
string
role
ibase_pconnect acts very much like
ibase_connect with two major differences.
First, when connecting, the function will first try to find a
(persistent) link that's already opened with the same parameters.
If one is found, an identifier for it will be returned instead of
opening a new connection. Second, the connection to the InterBase
server will not be closed when the execution of the script ends.
Instead, the link will remain open for future use
(ibase_close will not close links established
by ibase_pconnect). This type of link is
therefore called 'persistent'.
See also ibase_connect for the meaning of
parameters passed to this function. They are exactly the same.
ibase_close
Close a connection to an InterBase database
Description
int ibase_close
int
connection_id
Closes the link to an InterBase database that's associated with
a connection id returned from ibase_connect.
If the connection id is omitted, the last opened link is assumed.
Default transaction on link is committed, other transactions are
rolled back.
ibase_query
Execute a query on an InterBase database
Description
int ibase_query
int
link_identifier
string
query
int
bind_args
Performs a query on an InterBase database, returning a result
identifier for use with ibase_fetch_row,
ibase_fetch_object,
ibase_free_result and
ibase_free_query.
Although this function supports variable binding to parameter
placeholders, there is not very much meaning using this capability
with it. For real life use and an example, see
ibase_prepare and
ibase_execute.
ibase_fetch_row
Fetch a row from an InterBase database
Description
array ibase_fetch_row
int
result_identifier
Returns the next row specified by the result identifier obtained
using the ibase_query.
ibase_fetch_object
Get an object from a InterBase database
Description
object ibase_fetch_object
int
result_id
Fetches a row as a pseudo-object from a
result_id obtained either by
ibase_query or
ibase_execute.
<php
$dbh = ibase_connect ($host, $username, $password);
$stmt = 'SELECT * FROM tblname';
$sth = ibase_query ($dbh, $stmt);
while ($row = ibase_fetch_object ($sth)) {
print $row->email . "\n";
}
ibase_close ($dbh);
?>
See also ibase_fetch_row.
ibase_free_result
Free a result set
Description
int ibase_free_result
int
result_identifier
Free's a result set the has been created by
ibase_query.
ibase_prepare
Prepare a query for later binding of parameter placeholders and
execution
Description
int ibase_prepare
int
link_identifier
string query
Prepare a query for later binding of parameter placeholders and
execution (via ibase_execute).
ibase_execute
Execute a previously prepared query
Description
int ibase_execute
int
query
int
bind_args
Execute a query prepared by ibase_prepare.
This is a lot more effective than using ibase_query
if you are repeating a same kind of query several times with only
some parameters changing.
<?php
$updates = array(
1 => 'Eric',
5 => 'Filip',
7 => 'Larry'
);
$query = ibase_prepare("UPDATE FOO SET BAR = ? WHERE BAZ = ?");
while (list($baz, $bar) = each($updates)) {
ibase_execute($query, $bar, $baz);
}
?>
ibase_free_query
Free memory allocated by a prepared query
Description
int ibase_free_query
int
query
Free a query prepared by ibase_prepare.
ibase_timefmt
Sets the format of timestamp, date and time type columns returned from queries
Description
int ibase_timefmt
string
format
int
columntype
Sets the format of timestamp, date or time type columns returned
from queries. Internally, the columns are formatted by c-function
strftime(), so refer to it's documentation regarding to the format
of the string. columntype is one of the
constants IBASE_TIMESTAMP, IBASE_DATE and IBASE_TIME. If omitted,
defaults to IBASE_TIMESTAMP for backwards compatibility.
<?php
// InterBase 6 TIME-type columns will be returned in
// the form '05 hours 37 minutes'.
ibase_timefmt("%H hours %M minutes", IBASE_TIME);
?>
You can also set defaults for these formats with PHP configuration
directives ibase.timestampformat, ibase.dateformat and ibase.timeformat.
columntype was added in PHP 4.0. It has any
meaning only with InterBase version 6 and higher.
A backwards incompatible change happened in PHP 4.0 when PHP
configuration directive ibase.timeformat was renamed to
ibase.timestampformat and directives ibase.dateformat and
ibase.timeformat were added, so that the names would match better
their functionality.
ibase_num_fields
Get the number of fields in a result set
Description
int ibase_num_fields
int result_id
Returns an integer containing the number of fields in a result
set.
<?php
$dbh = ibase_connect ($host, $username, $password);
$stmt = 'SELECT * FROM tblname';
$sth = ibase_query ($dbh, $stmt);
if (ibase_num_fields($sth) > 0) {
while ($row = ibase_fetch_object ($sth)) {
print $row->email . "\n";
}
} else {
die ("No Results were found for your query");
}
ibase_close ($dbh);
?>
See also: ibase_field_info.
Ibase_num_fields is currently not functional
in PHP4.