FBIRD_QUERY
Purpose
Use the fbird_query function to execute a SQL
statement.
Syntax
<prepare> ::= fbird_query(
sql [, <bind_args>] ) | fbird_query(
conn_hndl, sql [, <bind_args>] ) |
fbird_query( trx_hndl, sql [, <bind_args>] ) |
fbird_query( conn_hndl, trx_hndl, sql [, <bind_args>]
)
<bind_args> ::= bind_arg |
bind_arg , <bind_args>
Element
|
Type
|
Description
|
sql
|
string
|
A valid SQL statement
|
conn_hndl
|
resource
|
A valid connection handle
|
trx_hndl
|
resource
|
A valid transaction handle
|
bind_arg
|
mixed
|
Optional values for parameter markers
|
<return>
|
mixed
|
A query handle on success, False on failure
|
Semantics
The fbird_query function executes a possibly
parameterised SQL statement. On successful execution of a SELECT
statement the function returns a result set handle, and for UPDATE,
DELETE and INSERT statements it returns the number of rows affecte;
It will return True for these statements if the query succeeded
without affecting any rows.
If neither a connection handle nor a transaction
handle is not provided, then the "default" connection will
be used. The default connection is assigned every time you call
fbird_connect or fbird_pconnect, so if you have multiple connections
it will be whichever one was connected last.
If a transaction handle is provided, the driver
will determine which connection handle it is associted with. If the
transaction spans multiple connections, the function will fail.
If a transaction handle is not provided, then the
"default" transaction will be used. If no default
transaction exists, a new default transaction is started. A default
transaction ends on commit or rollback. The default transaction
parameters are: IBASE_CONCURRENCY,
IBASE_WRITE, IBASE_WAIT and
IBASE_REC_VERSION.
Example
The below example connects to a server, executes a
query and fetches the result:
$srv_db =
'localhost:/path/to/your.fdb';
$conn = fbird_connect($srv_db,
$username, $password); $sql = 'SELECT email FROM tblname'; $res
= fbird_query($conn, $sql); while ($row =
fbird_fetch_object($res)) { echo $row->EMAIL,
"\n"; } fbird_free_result($res); fbird_close($conn);
See also
fbird_free_result,
fbird_num_fields,
fbird_field_info,
fbird_prepare
|