Base class for DBI querable and updatable items.
class DBIBaseTrans
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. |
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.
Commit the transaction to the database.
DBIBaseTrans.commit( )
Raises: |
|
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.
Performs a single delete query given a dictionary.
DBIBaseTrans.delete( table, data )
table | The table name on which to insert a new record. | ||||
data | The keys indicating the record to be deleted, as a dictionary. | ||||
Raises: |
|
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.
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.
Performs a single insertion query given a dictionary.
DBIBaseTrans.insert( table, data )
table | The table name on which to insert a new record. | ||||
data | The record to be inserted, as a dictionary. | ||||
Raises: |
|
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.
Execute a SQL query.
DBIBaseTrans.query( String )
String | SQL query |
Returns: | an instance of DBIRecordset If the performed query doesn't generate a recordset, it returns nil. |
Perform the SQL query and return the first field of the first record.
DBIBaseTrans.queryOne( String )
String | SQL query | ||
Returns: | The value of the first field of the first record | ||
Raises: |
|
Perform the SQL query and return only the first record as an array.
DBIBaseTrans.queryOneArray( String )
String | SQL query |
Returns: | Array populated array on nil on no results found. |
Perform the SQL query and return only the first record as a Dictionary.
DBIBaseTrans.queryOneDict( String )
String | SQL query |
Returns: | Dictionary populated with result or nil on no results found. |
Perform the SQL query and return only the first record as an Object.
DBIBaseTrans.queryOneObject( Object, String )
Object | object to populate |
String | SQL 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 the transaction (undo) to last commit point.
DBIBaseTrans.rollback( )
Raises: |
|
This does not close the transaction. You can rollback and try another operation within the same transaction as many times as you wish.
Performs a single update query given a dictionary.
DBIBaseTrans.update( table, data )
table | The table name on which to insert a new record. | ||||
data | The record to be inserted, as a dictionary. | ||||
Raises: |
|
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.