Firebird 2.0
PHP5 Programming

Overview of working with SQL

Working with a relational database revolves around sending SQL statements to the Firebird server and retrieving the results.


<sql_function> ::=
   | <execute>
   | <free_query>
   | <num_params>
   | <param_info>
   | <query>
   | <affected_rows>
   | <name_result>
   | <gen_id>
   | <errcode>
   | <errmsg>


The functions to deal with SQL statements are:

  • prepare
    The prepare function prepares a SQL statement for (possibly repeated) execution.

  • execute
    The execute function executes a previously prepared SQL statement with a fresh set of parameters (if any)

  • free_query
    The free_query function releases the resources tied up by a prepared query.

  • num_params
    The num_params function returns the number of parameters found in a SQL statement during preparation.

  • param_info
    The param_info function returns information about the type and size of the data exepcted by the Firebird server for each of the parameters in a prepared SQL statement.

  • query
    The query function prepares and executes a SQL statement in one step.

  • affected_rows
    The affected_rows function returns the number of rows affected by a previously executed statement.

  • name_result
    The name_result function names a result set, so that it can be referenced from SQL statements using the WHERE CURRENT OF clause.

  • gen_id
    The gen_id function returns a next sequence number from a Firebird sequence (a.k.a. generator).

  • errcode
    The errcode function returns the SQL error code of a previously executed SQL statement.

  • errmsg
    The errmessage function returns a descriptive error message text for a previously executed SQL statement.

The execute and query functions can return a result set. Working with such result sets and free'ing them after use is discussed in the next chapter.

previous page goto index next page

Legal information