database/database.bi

Summary
database/database.bi
LicenseCopyright © 2007-2011, FreeBASIC Extended Library Development Group
ext.database
StatementRepresents a prepared statement and allows access to the results of a statement passed to the database.
Functions
bindAttaches a value to anonymous parameters in the Query string.
executeExecutes the prepared statement on the database and steps through the resulting rows (if any).
numColumnsReturns the number of columns in the result set.
columnName
columnValue
finalizeReleases memory held by the statement.
handleDatabase dependant handle to this prepared statement.
ConnectionRepresents a connection to a database and provides a facility for prepared statements.
Functions
Component ConstructorInitializes a connection to a database using a connection string and a ext.database.DatabaseDriver.
Component ConstructorInitializes a database connection with only a ext.database.DatabaseDriver.
Copy ConstructorCopies the ext.database.DatabaseDriver and connect string from another Connection
connectConnects to the database using the passed connection string or the connection string passed to the constructor.
prepareFactory method to create Statements
queryExecute a no results one-off statement.
closeCloses the connection to the database.
getErrorReturns a string containing the current error message from the database.
handleReturns a pointer to the database dependant handle for this connection.

License

Copyright © 2007-2011, FreeBASIC Extended Library Development Group

Distributed under the FreeBASIC Extended Library Group license.  See accompanying file LICENSE.txt or copy at http://code.google.com/p/fb-extended-lib/wiki/License

ext.database

Statement

Represents a prepared statement and allows access to the results of a statement passed to the database.  This class is not meant to be created manually, only returned from the Connection.prepare function.

Summary
Functions
bindAttaches a value to anonymous parameters in the Query string.
executeExecutes the prepared statement on the database and steps through the resulting rows (if any).
numColumnsReturns the number of columns in the result set.
columnName
columnValue
finalizeReleases memory held by the statement.
handleDatabase dependant handle to this prepared statement.

Functions

bind

declare function bind overload (byval coli as integer,
byval value as integer) as StatusCode

Attaches a value to anonymous parameters in the Query string.

Supported types are integer, double, string and blob (pointer)

Anonymous parameters in a query string are the ? symbol.  Example: INSERT INTO ‘db’ (?,?,?)  WHERE ‘username’ = ? Has 4 anonymous parameters numbered 1 to 4.

execute

declare function execute( ) as StatusCode

Executes the prepared statement on the database and steps through the resulting rows (if any).

Returns

Database dependant error code.

numColumns

declare function numColumns( ) as integer

Returns the number of columns in the result set.

columnName

declare function columnName(byval iCol as integer) as string

Parameters

iColinteger number of column

Returns

The name of the column passed.

columnValue

declare function columnValue(byval iCol as integer) as string

Parameters

iColinteger number of column

Returns

The value in the column passed.

finalize

declare function finalize( ) as StatusCode

Releases memory held by the statement.

Returns

Database dependant error code.

handle

declare function handle() as any ptr

Returns

Database dependant handle to this prepared statement.

Connection

Represents a connection to a database and provides a facility for prepared statements.

Summary
Functions
Component ConstructorInitializes a connection to a database using a connection string and a ext.database.DatabaseDriver.
Component ConstructorInitializes a database connection with only a ext.database.DatabaseDriver.
Copy ConstructorCopies the ext.database.DatabaseDriver and connect string from another Connection
connectConnects to the database using the passed connection string or the connection string passed to the constructor.
prepareFactory method to create Statements
queryExecute a no results one-off statement.
closeCloses the connection to the database.
getErrorReturns a string containing the current error message from the database.
handleReturns a pointer to the database dependant handle for this connection.

Functions

Component Constructor

Initializes a connection to a database using a connection string and a ext.database.DatabaseDriver.

Parameters

connectsta database dependant connection string.
da pointer to a ext.database.DatabaseDriver

Component Constructor

Initializes a database connection with only a ext.database.DatabaseDriver.  You must pass a connection string to the connect function.

Parameters

da pointer to a ext.database.DatabaseDriver

Copy Constructor

Copies the ext.database.DatabaseDriver and connect string from another Connection

connect

declare function connect(byref connectst as string =  "") as StatusCode

Connects to the database using the passed connection string or the connection string passed to the constructor.

Parameters

connectstoptional (if passed to constructor) database dependant connection string

Returns

Database dependant error code.

prepare

declare function prepare(byref sql as string) as Statement ptr

Factory method to create Statements

Parameters

sqlthe SQL statement you want to pass to the database.

Returns

Pointer to a Statement.  You must delete this when you are done.

query

declare function query(byref sql as const string) as StatusCode

Execute a no results one-off statement.

Returns

Database dependant error code.

close

declare function close() as StatusCode

Closes the connection to the database.  This invalidates any remaining <Statment> objects.

Returns

Database dependant error code

getError

declare function getError () as string

Returns a string containing the current error message from the database.

handle

declare function handle() as any ptr

Returns a pointer to the database dependant handle for this connection.

declare function bind overload (byval coli as integer,
byval value as integer) as StatusCode
Attaches a value to anonymous parameters in the Query string.
declare function execute( ) as StatusCode
Executes the prepared statement on the database and steps through the resulting rows (if any).
declare function numColumns( ) as integer
Returns the number of columns in the result set.
declare function columnName(byval iCol as integer) as string
declare function columnValue(byval iCol as integer) as string
declare function finalize( ) as StatusCode
Releases memory held by the statement.
declare function handle() as any ptr
Database dependant handle to this prepared statement.
type DatabaseDriver
A group of function pointers to enable access to a database.
Represents a connection to a database and provides a facility for prepared statements.
declare function connect(byref connectst as string =  "") as StatusCode
Connects to the database using the passed connection string or the connection string passed to the constructor.
declare function prepare(byref sql as string) as Statement ptr
Factory method to create Statements
Represents a prepared statement and allows access to the results of a statement passed to the database.
declare function query(byref sql as const string) as StatusCode
Execute a no results one-off statement.
declare function close() as StatusCode
Closes the connection to the database.
declare function getError () as string
Returns a string containing the current error message from the database.
declare function handle() as any ptr
Returns a pointer to the database dependant handle for this connection.