Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics > Database API

About Database API

Scroll Prev Next More

 

Methods

Method

Description

SetConnection()

Sets the current database link when working with multiple database connections.

Exec()

Executes an SQL query using the current active connection.

Query()

Executes an SQL Query that returns data.

LastId()

Returns the last inserted autoincrement field value under the current connection.

LastError()

Returns the last error message under the current connection.

Insert()

Adds records to the database.

Update()

Updates records in the database.

Delete()

Deletes records from the database.

Select()

Retrieves data from the database.

PrepareSQL()

Prepares an SQL query to use with SQL variables.

DBLookup()

Executes a SQL query passed as a parameter. Returns the first value of the first entry or null if nothing is found.

Error handling

 

Database API functions will not stop execution after encountering a SQL error. To properly handle errors use LastError() function.

 

If you need your code to break in case of a SQL error you can use old-style functions like CustomQuery().

See also:

QueryResult object: fetchNumeric()

QueryResult object: value()

QueryResult object: fetchAssoc()

Using SQL variables