Class DBIBaseTrans[in The DBI Falcon Module.]

Base class for DBI querable and updatable items.

class DBIBaseTrans

more...

Summary

commit()Commit the transaction to the database.
delete()Performs a single delete query given a dictionary.
getLastError()Get the last error string from the database server.
insert()Performs a single insertion query given a dictionary.
query()Execute a SQL query.
queryOne()Perform the SQL query and return the first field of the first record.
queryOneArray()Perform the SQL query and return only the first record as an array.
queryOneDict()Perform the SQL query and return only the first record as a Dictionary.
queryOneObject()Perform the SQL query and return only the first record as an Object.
rollback()Rollback the transaction (undo) to last commit point.
update()Performs a single update query given a dictionary.

Detailed description

Base class for DBI querable and updatable items.

This class is the base for database handles and single transactions (dabatase handle portions that some database engine is able to open separately).

The vast majority of common query operations available in databases are exposed by this class, which is inhertited by DBIHandle and DBITransaction.

Methods

commit()

Commit the transaction to the database.

DBIBaseTrans.commit( )

Raises:
DBIErroron failure

This method is available also on the database handler (main transaction), even if it's transaction-oriented, because some engine can provide a commit/rollback feature while not providing a full parallel transaction support.

This does not close the transaction. You can perform a commit at safe steps within the transaction if necessary.

delete()

Performs a single delete query given a dictionary.

DBIBaseTrans.delete( table, data )

tableThe table name on which to insert a new record.
dataThe keys indicating the record to be deleted, as a dictionary.
Raises:
DBIErrorif the query doesn't return any result.
ParamErrorif the data wasn't adequate to delete a record.

This method automathises the task of creating the "update" sql query given some variable data to be inserted. It actually expands into a complete SQL "update" query that is then sent to the engine.

To determine a primary key or set of keys to insolate one (or more) records to be updated, declare the keys as OOB strings (i.e. via the oob() function). They won't be used in the 'SET' clause, and will form a 'where' clause in which they are all required (joint with an 'and' value).

This function will refuse to update in case there isn't at least a key field in the dictionary.

getLastError()

Get the last error string from the database server.

DBIBaseTrans.getLastError( )

Returns:String

This string is database server dependent. It is provided to get detailed information as to the error.

insert()

Performs a single insertion query given a dictionary.

DBIBaseTrans.insert( table, data )

tableThe table name on which to insert a new record.
dataThe record to be inserted, as a dictionary.
Raises:
DBIErrorif the query generates an error in the SQL engine.
ParamErrorif the data wasn't adequate to be inserted.

This method automathises the task of creating the "insert" sql query given some variable data to be inserted. It actually expands into a complete SQL "insert" query that is then sent to the engine.

Note: Strings are expanded into utf-8 values, so the engine must support it.

query()

Execute a SQL query.

DBIBaseTrans.query( String )

StringSQL query
Returns: an instance of DBIRecordset If the performed query doesn't generate a recordset, it returns nil.

queryOne()

Perform the SQL query and return the first field of the first record.

DBIBaseTrans.queryOne( String )

StringSQL query
Returns:The value of the first field of the first record
Raises:
DBIErrorif the query doesn't return any result.

queryOneArray()

Perform the SQL query and return only the first record as an array.

DBIBaseTrans.queryOneArray( String )

StringSQL query
Returns:Array populated array on nil on no results found.

queryOneDict()

Perform the SQL query and return only the first record as a Dictionary.

DBIBaseTrans.queryOneDict( String )

StringSQL query
Returns:Dictionary populated with result or nil on no results found.

queryOneObject()

Perform the SQL query and return only the first record as an Object.

DBIBaseTrans.queryOneObject( Object, String )

Objectobject to populate
StringSQL query
Returns:populated object on success, or nil on no results found.

Refer to documentation on DBIRecord for more information on using the DBI object query system.

rollback()

Rollback the transaction (undo) to last commit point.

DBIBaseTrans.rollback( )

Raises:
DBIErroron failure

This does not close the transaction. You can rollback and try another operation within the same transaction as many times as you wish.

update()

Performs a single update query given a dictionary.

DBIBaseTrans.update( table, data )

tableThe table name on which to insert a new record.
dataThe record to be inserted, as a dictionary.
Raises:
DBIErrorif the query doesn't return any result.
ParamErrorif the data wasn't adequate to update the table.

This method automathises the task of creating the "update" sql query given some variable data to be inserted. It actually expands into a complete SQL "update" query that is then sent to the engine.

To determine a primary key or set of keys to insolate one (or more) records to be updated, declare the keys as OOB strings (i.e. via the oob() function). They won't be used in the 'SET' clause, and will form a 'where' clause in which they are all required (joint with an 'and' value).

This function will refuse to update in case there isn't at least a key field in the dictionary.


Made with faldoc 2.0.0