SourceMod::IDatabase Class Reference

Encapsulates a database connection. More...

#include <public/IDBDriver.h>

List of all members.

Public Member Functions

virtual bool Close ()=0
 Disconnects the database and frees its associated memory. Note that the actual object will not be freed until all open references have been closed.
virtual const char * GetError (int *errorCode=NULL)=0
 Error code and string returned by the last operation on this connection.
virtual bool DoSimpleQuery (const char *query)=0
 Prepares and executes a query in one step, and discards any return data.
virtual IQueryDoQuery (const char *query)=0
 Prepares and executes a query in one step, and returns the resultant data set.
virtual IPreparedQueryPrepareQuery (const char *query, char *error, size_t maxlength, int *errCode=NULL)=0
 Prepares a query statement for multiple executions and/or binding marked parameters (? in MySQL/sqLite, $n in PostgreSQL).
virtual bool QuoteString (const char *str, char buffer[], size_t maxlen, size_t *newSize)=0
virtual unsigned int GetAffectedRows ()=0
 Number of rows affected by the last execute.
virtual unsigned int GetInsertID ()=0
 Retrieves the last insert ID on this database connection.
virtual bool LockForFullAtomicOperation ()=0
 Locks the database for an atomic query+retrieval operation.
virtual void UnlockFromFullAtomicOperation ()=0
 Unlocks a locked atomic fetch.
virtual void IncReferenceCount ()=0
 Increases the reference count on the database.
virtual IDBDriverGetDriver ()=0
 Returns the parent driver.
virtual bool DoSimpleQueryEx (const char *query, size_t len)=0
 Prepares and executes a binary query in one step, and discards any return data.
virtual IQueryDoQueryEx (const char *query, size_t len)=0
 Prepares and executes a binary query in one step, and returns the resultant data set.


Detailed Description

Encapsulates a database connection.

Definition at line 425 of file IDBDriver.h.


Member Function Documentation

virtual bool SourceMod::IDatabase::Close (  )  [pure virtual]

Disconnects the database and frees its associated memory. Note that the actual object will not be freed until all open references have been closed.

It is guaranteed that an IDatabase pointer won't be destroyed until all open IQuery or IPreparedQuery pointers are closed.

This function is thread safe.

Returns:
True if object was destroyed, false if references are remaining.

virtual const char* SourceMod::IDatabase::GetError ( int *  errorCode = NULL  )  [pure virtual]

Error code and string returned by the last operation on this connection.

This function is not thread safe and must be included in any locks.

Parameters:
errorCode Optional pointer to retrieve an error code.
Returns:
Error string pointer (empty if none).

virtual bool SourceMod::IDatabase::DoSimpleQuery ( const char *  query  )  [pure virtual]

Prepares and executes a query in one step, and discards any return data.

This function is not thread safe and must be included in any locks.

Parameters:
query Query string.
Returns:
True on success, false otherwise.

virtual IQuery* SourceMod::IDatabase::DoQuery ( const char *  query  )  [pure virtual]

Prepares and executes a query in one step, and returns the resultant data set.

Note: If a query contains more than one result set, each result set must be processed before a new query is started.

This function is not thread safe and must be included in any locks.

Parameters:
query Query string.
Returns:
IQuery pointer on success, NULL otherwise.

virtual IPreparedQuery* SourceMod::IDatabase::PrepareQuery ( const char *  query,
char *  error,
size_t  maxlength,
int *  errCode = NULL 
) [pure virtual]

Prepares a query statement for multiple executions and/or binding marked parameters (? in MySQL/sqLite, $n in PostgreSQL).

This function is not thread safe and must be included in any locks.

Parameters:
query Query string.
error Error buffer.
maxlength Maximum length of the error buffer.
errCode Optional pointer to store a driver-specific error code.
Returns:
IPreparedQuery pointer on success, NULL otherwise.

virtual bool SourceMod::IDatabase::QuoteString ( const char *  str,
char  buffer[],
size_t  maxlen,
size_t *  newSize 
) [pure virtual]

Quotes a string for insertion into a query.

Parameters:
str Source string.
buffer Buffer to store new string (should not overlap source string).
maxlen Maximum length of the output buffer.
newSize Pointer to store the output size.
Returns:
True on success, false if the output buffer is not big enough. If not big enough, the required buffer size is passed through newSize.

virtual unsigned int SourceMod::IDatabase::GetAffectedRows (  )  [pure virtual]

Number of rows affected by the last execute.

This function is not thread safe and must be included in any locks.

Returns:
Number of rows affected by the last execute.

virtual unsigned int SourceMod::IDatabase::GetInsertID (  )  [pure virtual]

Retrieves the last insert ID on this database connection.

This function is not thread safe and must be included in any locks.

Returns:
Row insertion ID of the last execute, if any.

virtual bool SourceMod::IDatabase::LockForFullAtomicOperation (  )  [pure virtual]

Locks the database for an atomic query+retrieval operation.

Returns:
True on success, false if not supported.

virtual void SourceMod::IDatabase::IncReferenceCount (  )  [pure virtual]

Increases the reference count on the database.

This function is thread safe.

virtual IDBDriver* SourceMod::IDatabase::GetDriver (  )  [pure virtual]

Returns the parent driver.

This function is thread safe.

virtual bool SourceMod::IDatabase::DoSimpleQueryEx ( const char *  query,
size_t  len 
) [pure virtual]

Prepares and executes a binary query in one step, and discards any return data.

This function is not thread safe and must be included in any locks.

Parameters:
query Query string.
length Length of query string.
Returns:
True on success, false otherwise.

virtual IQuery* SourceMod::IDatabase::DoQueryEx ( const char *  query,
size_t  len 
) [pure virtual]

Prepares and executes a binary query in one step, and returns the resultant data set.

Note: If a query contains more than one result set, each result set must be processed before a new query is started.

This function is not thread safe and must be included in any locks.

Parameters:
query Query string.
Returns:
IQuery pointer on success, NULL otherwise.


The documentation for this class was generated from the following file:
Generated on Fri Nov 21 07:10:03 2008 for SourceMod SDK by  doxygen 1.5.1