Qore Programming Language Reference Manual
1.8.0
|
Provides transparent per-thread, per-transaction datasource connection pooling. More...
Public Member Methods | |
nothing | beginTransaction () |
Manually allocates a persistent connection from the pool to the calling thread. More... | |
nothing | clearEventQueue () |
Clears the queue object for DBI events on the pool. More... | |
clearWarningCallback () | |
clears any connection delay warning callback from the object More... | |
nothing | commit () |
Commits the current transaction and releases the connection to the pool. More... | |
constructor (string driver, *string user, *string pass, *string db, *string encoding, *string host, softint min=3, softint max=10, softint port=0, *Qore::Thread::Queue queue, auto arg) | |
Creates the DatasourcePool object; attempts to load a DBI driver if the driver is not already present in Qore. More... | |
constructor (string desc, *Qore::Thread::Queue queue, auto arg) | |
Creates a DatasourcePool object from a single string giving all parameters that can be parsed by parse_datasource() More... | |
constructor (hash< auto > opts, *Qore::Thread::Queue queue, auto arg) | |
Creates a DatasourcePool object from a hash argument giving parameters for the constructor. More... | |
copy () | |
Creates a new Datasource object with the same driver as the original and copies of all the connection parameters. More... | |
bool | currentThreadInTransaction () |
Returns True if the current thread is in a transaction (i.e. has a dedicated datasource allocation), False if not. More... | |
destructor () | |
Throws an exception if any transactions are in progress and returns immediately; the object is destroyed after any in-progress requests are completed. More... | |
auto | exec (string sql,...) |
Allocates a persistent connection to the current thread from the pool (if one has not already been allocated) and executes an SQL command on the server and returns either the integer row count (for example, for updates, inserts, and deletes) or the data retrieved (for example, if a stored procedure is executed that returns values) More... | |
auto | execRaw (string sql) |
Allocates a persistent connection to the current thread from the pool (if one has not already been allocated) and executes an SQL command on the server and returns either the row count (for example, for updates and inserts) or the data retrieved (for example, if a stored procedure is executed that returns values) More... | |
int | getCapabilities () |
Returns an integer bitfield of DBI driver capabilities. More... | |
list< auto > | getCapabilityList () |
Returns a list of strings giving the capabilities of the current DBI driver. More... | |
auto | getClientVersion () |
Retrieves the driver-specific client library version information; this method may not be implemented for all drivers. More... | |
hash< auto > | getConfigHash () |
Returns a datasource hash describing the configuration of the current object. More... | |
string | getConfigString () |
Returns a string giving the configuration of the current object in a format that can be parsed by parse_datasource() More... | |
*string | getDBCharset () |
Retrieves the database-specific charset set encoding for the object. More... | |
*string | getDBEncoding () |
Retrieves the database-specific charset set encoding for the object. More... | |
*string | getDBName () |
Returns the database name parameter as a string or NOTHING if none is set. More... | |
string | getDriverName () |
Returns the name of the driver used for the object. More... | |
int | getErrorTimeout () |
Returns the error timeout period for waiting for a connection to come free as an integer giving milliseconds; note that timeout values less than or equal to zero mean that requests for a connection will wait indefinitely. More... | |
*string | getHostName () |
Returns the hostname parameter as a string or NOTHING if none is set. More... | |
int | getMaximum () |
Returns the maximum number of connections in this object. More... | |
int | getMinimum () |
Returns the minimum number of connections in this object. More... | |
string | getOSCharset () |
Returns the Qore character encoding name for the object as a string or "(unknown)" if none is set. More... | |
*string | getOSEncoding () |
Returns the Qore character encoding name for the object as a string or NOTHING if none is set. More... | |
auto | getOption (string opt) |
Returns the current value for the given option. More... | |
hash< auto > | getOptionHash () |
returns the valid options for the driver associated with the Datasource with descriptions and current values for the current Datasource object More... | |
*string | getPassword () |
Returns the password parameter as a string or NOTHING if none is set. More... | |
*int | getPort () |
Gets the port number that will be used for the next connection to the server. More... | |
AbstractSQLStatement | getSQLStatement () |
Returns an AbstractSQLStatement object based on the current database connection object. More... | |
auto | getServerVersion () |
Returns the driver-specific server version data for the current connection. More... | |
*hash< auto > | getUsageInfo () |
Returns a hash with usage information about the DatasourcePool object. More... | |
*string | getUserName () |
Returns the username parameter as a string or NOTHING if none is set. More... | |
bool | inTransaction () |
Returns True if a transaction is currently in progress (meaning in this case that a datasource form the pool is dedicated to the calling thread), False if not. More... | |
nothing | rollback () |
Rolls back the current transaction and releases the connection to the pool. More... | |
auto | select (string sql,...) |
Executes an SQL select statement on the server and returns the result as a hash (column names) of lists (column values per row) More... | |
auto | selectRow (string sql,...) |
Executes an SQL select statement on the server and returns the first row as a hash (the column values) More... | |
auto | selectRows (string sql,...) |
Executes an SQL select statement on the server and returns the result as a list (rows) of hashes (the column values) More... | |
setErrorTimeout (timeout ts) | |
Sets the timeout period for waiting for a connection to come free; note that timeout values less than or equal to zero mean that requests for a connection will wait indefinitely. More... | |
nothing | setEventQueue (Qore::Thread::Queue queue, auto arg) |
Sets a queue object for DBI events on the pool. More... | |
setWarningCallback (timeout ms, code callback, auto arg) | |
sets a connection delay warning callback to be called any time the delay assigning a connection from the pool exceeds the given timeout in milliseconds More... | |
string | toString () |
Returns a string with technical information about the object. More... | |
auto | vexec (string sql, *softlist< auto > vargs) |
Allocates a persistent connection to the current thread from the pool (if one has not already been allocated) and executes SQL code on the DB connection, taking a list for all bind arguments. More... | |
auto | vselect (string sql, *softlist< auto > vargs) |
Executes a select statement on the server and returns the results in a hash (column names) of lists (column values per row), taking a list for all bind arguments. More... | |
auto | vselectRow (string sql, *softlist< auto > vargs) |
Executes a select statement on the server and returns the first row as a hash (column names and values), taking a list for all bind arguments. More... | |
auto | vselectRows (string sql, *softlist< auto > vargs) |
Executes a select statement on the server and returns the results in a list (rows) of hashes (column names and values), taking a list for all bind arguments. More... | |
Public Member Methods inherited from Qore::SQL::AbstractDatasource | |
bool | currentThreadInTransaction () |
Should return True if the current thread is in a transaction with this object, must be re-implemented in subclasses to provide the desired functionality. More... | |
auto | getOption (string opt) |
Returns the current value for the given option. More... | |
hash< auto > | getOptionHash () |
Returns the valid options for the driver associated with the AbstractDatasource with descriptions and current values for the current AbstractDatasource object. More... | |
AbstractSQLStatement | getSQLStatement () |
Returns an AbstractSQLStatement object based on the current database connection object. More... | |
Public Member Methods inherited from Qore::Serializable | |
constructor () | |
The constructor does not perform any action; this class is just used to mark a class as serializable by inheriting this class. | |
copy () | |
The copy constructor does not perform any action; this class is just used to mark a class as serializable by inheriting this class. | |
serialize (OutputStream stream) | |
converts the object to binary data representing the object More... | |
binary | serialize () |
converts the object to binary data representing the object More... | |
hash< SerializationInfo > | serializeToData () |
converts the object to a serialization hash representing the object More... | |
Additional Inherited Members | |
Static Public Member Methods inherited from Qore::Serializable | |
static auto | deserialize (InputStream stream) |
Deserializes data produced with serialize() and returns the value represented by the data. More... | |
static auto | deserialize (binary bin) |
Deserializes data produced with serialize() and returns the value represented by the data. More... | |
static auto | deserialize (string bin) |
Deserializes data produced with serialize() and returns the value represented by the data. More... | |
static auto | deserialize (hash< SerializationInfo > data) |
Deserializes data produced with serializeToData() and returns the value represented by the data. More... | |
static hash< SerializationInfo > | deserializeToData (InputStream stream) |
Deserializes data produced with serialize() and returns the value represented by the data. More... | |
static hash< SerializationInfo > | deserializeToData (binary bin) |
Deserializes data produced with serialize() and returns the value represented by the data. More... | |
static | serialize (auto val, OutputStream stream) |
serializes the data and writes the serialized data to the given output stream More... | |
static binary | serialize (auto val) |
serializes the data and returns the serialized data as a binary object More... | |
static hash< SerializationInfo > | serializeToData (auto val) |
converts the value to a serialization hash representing the value More... | |
Provides transparent per-thread, per-transaction datasource connection pooling.
"select for update"
), call DatasourcePool::beginTransaction() first to manually dedicate a Datasource to the thread before calling the select method. Otherwise statements that should be in the same transaction may be executed in different connections.DATASOURCE-TRANSACTION-EXCEPTION
exception is raised describing the situation.When deserializing, any datasource event queue is lost; only the connection information is propagated in the deserialized copy.
|
virtual |
Manually allocates a persistent connection from the pool to the calling thread.
This method should be called when a transaction will be started with a DatasourcePool::select() method (or DatasourcePool::vselect(), etc).
This method does not make any communication with the server to start a transaction; it only allocates a persistent connection to the current thread in Qore.
To release the connection, call DatasourcePool::commit() or DatasourcePool::rollback()
Implements Qore::SQL::AbstractDatasource.
nothing Qore::SQL::DatasourcePool::clearEventQueue | ( | ) |
Clears the queue object for DBI events on the pool.
Qore::SQL::DatasourcePool::clearWarningCallback | ( | ) |
clears any connection delay warning callback from the object
|
virtual |
Commits the current transaction and releases the connection to the pool.
Implements Qore::SQL::AbstractDatasource.
Qore::SQL::DatasourcePool::constructor | ( | hash< auto > | opts, |
*Qore::Thread::Queue | queue, | ||
auto | arg | ||
) |
Creates a DatasourcePool object from a hash argument giving parameters for the constructor.
opts | a hash giving parameters for the new datasource with the following possible keys (the "type" key is mandatory, also usable with the output of the parse_datasource() function):
|
queue | An optional Queue object to receive datasource events; note that the Queue passed cannot have any maximum size set or a QUEUE-ERROR will be thrown; passing NOTHING will clear any event queue |
arg | an optional argument to be included in the arg key of datasource events |
DATASOURCEPOOL-UNSUPPORTED-DATABASE | DBI driver cannot be loaded |
DATASOURCEPOOL-CONSTRUCTOR-ERROR | missing or invalid "driver" key, other key name not assigned to a string; "port" value is <= 0; invalid "min" or "max" keys |
DBI-OPTION-ERROR | unknown or unsupported option passed to driver |
Qore::SQL::DatasourcePool::constructor | ( | string | desc, |
*Qore::Thread::Queue | queue, | ||
auto | arg | ||
) |
Creates a DatasourcePool object from a single string giving all parameters that can be parsed by parse_datasource()
desc | a datasource description string in the format that can be parsed by parse_datasource() |
queue | An optional Queue object to receive datasource events; note that the Queue passed cannot have any maximum size set or a QUEUE-ERROR will be thrown; passing NOTHING will clear any event queue |
arg | an optional argument to be included in the arg key of datasource events |
DATASOURCE-UNSUPPORTED-DATABASE | DBI driver cannot be loaded |
DATASOURCE-CONSTRUCTOR-ERRO | missing required parameter for connection; port value is <= 0 |
DBI-OPTION-ERROR | unknown or unsupported option passed to driver |
Qore::SQL::DatasourcePool::constructor | ( | string | driver, |
*string | user, | ||
*string | pass, | ||
*string | db, | ||
*string | encoding, | ||
*string | host, | ||
softint | min = 3 , |
||
softint | max = 10 , |
||
softint | port = 0 , |
||
*Qore::Thread::Queue | queue, | ||
auto | arg | ||
) |
Creates the DatasourcePool object; attempts to load a DBI driver if the driver is not already present in Qore.
driver | The name of the DBI driver for the Datasource. See SQL Constants for builtin constants for DBI drivers shipped with Qore, or see the DBI driver documentation to use an add-on driver (this string should be the name of the driver to be loaded) |
user | The user name for the new connection. Also see Datasource::setUserName() for a method that allows this parameter to be set after the constructor. |
pass | The password for the new connection. Also see Datasource::setPassword() for a method that allows this parameter to be set after the constructor. |
db | The database name for the new connection. Also see Datasource::setDBName() for a method that allows this parameter to be set after the constructor. |
encoding | The database-specific name of the character encoding to use for the new connection. Also see Datasource::setDBCharset() for a method that allows this parameter to be set after the constructor. If no value is passed for this parameter, then the database character encoding corresponding to the default character encoding will be used instead. |
host | The host name for the new connection. Also see Datasource::setHostName() for a method that allows this parameter to be set after the constructor. |
min | The minimum number of connections in the pool (this number of connections is opened in the constructor) |
max | The maximum number of connections in the pool (not more than this number of connections will be opened) |
port | The port number for the new connection. Also see Datasource::setPort() for a method that allows this parameter to be set after the constructor. |
queue | An optional Queue object to receive datasource events; note that the Queue passed cannot have any maximum size set or a QUEUE-ERROR will be thrown; passing NOTHING will clear any event queue |
arg | an optional argument to be included in the arg key of datasource events |
DATASOURCEPOOL-UNSUPPORTED-DATABASE | DBI driver cannot be found |
DATASOURCEPOOL-CONSTRUCTOR-ERROR | invalid min, max, or port argument |
DBI-OPTION-ERROR | unknown or unsupported option passed to driver |
Qore::SQL::DatasourcePool::copy | ( | ) |
Creates a new Datasource object with the same driver as the original and copies of all the connection parameters.
bool Qore::SQL::DatasourcePool::currentThreadInTransaction | ( | ) |
Returns True if the current thread is in a transaction (i.e. has a dedicated datasource allocation), False if not.
Qore::SQL::DatasourcePool::destructor | ( | ) |
Throws an exception if any transactions are in progress and returns immediately; the object is destroyed after any in-progress requests are completed.
DATASOURCEPOOL-ERROR | The destructor was called while a transaction was still in progress |
|
virtual |
Allocates a persistent connection to the current thread from the pool (if one has not already been allocated) and executes an SQL command on the server and returns either the integer row count (for example, for updates, inserts, and deletes) or the data retrieved (for example, if a stored procedure is executed that returns values)
This method also accepts all bind parameters (%d
, %v
, %s
, etc) as documented in Binding by Value and Placeholder
sql | The SQL command to execute on the server |
... | Include any values to be bound (using %v in the command string) or placeholder specifications (using : key_name in the command string) in order after the command string |
Implements Qore::SQL::AbstractDatasource.
|
virtual |
Allocates a persistent connection to the current thread from the pool (if one has not already been allocated) and executes an SQL command on the server and returns either the row count (for example, for updates and inserts) or the data retrieved (for example, if a stored procedure is executed that returns values)
This method does not do any variable binding, so it's useful for example for DDL statements etc
sql | The SQL command to execute on the server; this string will not be subjected to any transformations for variable binding |
Implements Qore::SQL::AbstractDatasource.
int Qore::SQL::DatasourcePool::getCapabilities | ( | ) |
Returns an integer bitfield of DBI driver capabilities.
list<auto> Qore::SQL::DatasourcePool::getCapabilityList | ( | ) |
Returns a list of strings giving the capabilities of the current DBI driver.
|
virtual |
Retrieves the driver-specific client library version information; this method may not be implemented for all drivers.
Implements Qore::SQL::AbstractDatasource.
|
virtual |
Returns a datasource hash describing the configuration of the current object.
Implements Qore::SQL::AbstractDatasource.
|
virtual |
Returns a string giving the configuration of the current object in a format that can be parsed by parse_datasource()
Implements Qore::SQL::AbstractDatasource.
*string Qore::SQL::DatasourcePool::getDBCharset | ( | ) |
Retrieves the database-specific charset set encoding for the object.
A method synonym for DatasourcePool::getDBEncoding() kept for backwards-compatibility
|
virtual |
Retrieves the database-specific charset set encoding for the object.
Implements Qore::SQL::AbstractDatasource.
|
virtual |
Returns the database name parameter as a string or NOTHING if none is set.
Implements Qore::SQL::AbstractDatasource.
|
virtual |
Returns the name of the driver used for the object.
Implements Qore::SQL::AbstractDatasource.
int Qore::SQL::DatasourcePool::getErrorTimeout | ( | ) |
Returns the error timeout period for waiting for a connection to come free as an integer giving milliseconds; note that timeout values less than or equal to zero mean that requests for a connection will wait indefinitely.
|
virtual |
Returns the hostname parameter as a string or NOTHING if none is set.
Implements Qore::SQL::AbstractDatasource.
int Qore::SQL::DatasourcePool::getMaximum | ( | ) |
Returns the maximum number of connections in this object.
int Qore::SQL::DatasourcePool::getMinimum | ( | ) |
Returns the minimum number of connections in this object.
auto Qore::SQL::DatasourcePool::getOption | ( | string | opt | ) |
Returns the current value for the given option.
opt | the option to get |
DBI-OPTION-ERROR | unknown or unsupported option passed to driver |
hash<auto> Qore::SQL::DatasourcePool::getOptionHash | ( | ) |
returns the valid options for the driver associated with the Datasource with descriptions and current values for the current Datasource object
"desc"
: a string description of the option"type"
: a string giving the data type restriction for the option"value"
: the current value of the optionstring Qore::SQL::DatasourcePool::getOSCharset | ( | ) |
Returns the Qore character encoding name for the object as a string or "(unknown)"
if none is set.
"(unknown)"
if none is set
|
virtual |
Returns the Qore character encoding name for the object as a string or NOTHING if none is set.
Implements Qore::SQL::AbstractDatasource.
|
virtual |
Returns the password parameter as a string or NOTHING if none is set.
Implements Qore::SQL::AbstractDatasource.
|
virtual |
Gets the port number that will be used for the next connection to the server.
Invalid port numbers will cause an exception to be thrown when the connection is opened
Implements Qore::SQL::AbstractDatasource.
|
virtual |
Returns the driver-specific server version data for the current connection.
Implements Qore::SQL::AbstractDatasource.
AbstractSQLStatement Qore::SQL::DatasourcePool::getSQLStatement | ( | ) |
Returns an AbstractSQLStatement object based on the current database connection object.
SQLSTATEMENT-ERROR | the DBI driver for the given object does not support the prepared statement API |
*hash<auto> Qore::SQL::DatasourcePool::getUsageInfo | ( | ) |
Returns a hash with usage information about the DatasourcePool object.
callback
, timeout
, and optionally arg
keys are only set if a warning callback is set):callback:
the closure or call reference set as the warning callbacktimeout:
an integer giving the timeout threshold in milliseconds before the warning callback is executedarg:
an optional argument passed to the warning callbackwait_max:
the maximum number of microseconds that threads have had to wait for a free connectionstats_reqs:
the total number of requests for connections / transactions on this DatasourcePoolstats_hits:
the total number of requests for connections / transactions on this DatasourcePool that did not have to wait for a connectionwait_max
is reported in microseconds (1 ms = 1000 us) while the warning timeout has a resolution of milliseconds
|
virtual |
Returns the username parameter as a string or NOTHING if none is set.
Implements Qore::SQL::AbstractDatasource.
|
virtual |
Returns True if a transaction is currently in progress (meaning in this case that a datasource form the pool is dedicated to the calling thread), False if not.
Implements Qore::SQL::AbstractDatasource.
|
virtual |
Rolls back the current transaction and releases the connection to the pool.
Implements Qore::SQL::AbstractDatasource.
|
virtual |
Executes an SQL select statement on the server and returns the result as a hash (column names) of lists (column values per row)
The return format of this method is suitable for use with context statements, for easy iteration and processing of query results. Alternatively, the HashListIterator class can be used to iterate the return value of this method.
Additionally, this format is a more efficient format than that returned by the Datasource::selectRows() method, because the column names are not repeated for each row returned. Therefore, for retrieving anything greater than small amounts of data, it is recommended to use this method instead of Datasource::selectRows().
This method also accepts all bind parameters (%d
, %v
, %s
, etc) as documented in Binding by Value and Placeholder
This method does not retain the datasource connection for the current thread if one was not already allocated before this method is called, so to execute select statements that begin a transaction (such as "select for update"
), execute DatasourcePool::beginTransaction() first to ensure that the connection is dedicated to the calling thread.
sql | The SQL command to execute on the server |
... | Include any values to be bound (using %v in the command string) or placeholder specifications (using : key_name in the command string) in order after the command string |
Implements Qore::SQL::AbstractDatasource.
|
virtual |
Executes an SQL select statement on the server and returns the first row as a hash (the column values)
If more than one row is returned, then it is treated as an error and a DBI-SELECT-ROW-ERROR
is returned (however the DBI driver should raise its own exception here to avoid retrieving more than one row from the server). For a similar method taking a list for all bind arguments, see DatasourcePool::vselectRow().
This method also accepts all bind parameters (%d
, %v
, %s
, etc) as documented in Binding by Value and Placeholder
This method does not retain the datasource connection for the current thread if one was not already allocated before this method is called, so to execute select statements that begin a transaction (such as "select for update"
), execute DatasourcePool::beginTransaction() first to ensure that the connection is dedicated to the calling thread.
sql | The SQL command to execute on the server |
... | Include any values to be bound (using %v in the command string) or placeholder specifications (using : key_name in the command string) in order after the command string |
DBI-SELECT-ROW-ERROR | more than 1 row retrieved from the server |
Implements Qore::SQL::AbstractDatasource.
|
virtual |
Executes an SQL select statement on the server and returns the result as a list (rows) of hashes (the column values)
The return format of this method is not as memory efficient as that returned by the DatasourcePool::select() method, therefore for larger amounts of data, it is recommended to use DatasourcePool::select().
The usual return value of this method can be iterated with the ListHashIterator class.
This method also accepts all bind parameters (%d
, %v
, %s
, etc) as documented in Binding by Value and Placeholder
This method does not retain the datasource connection for the current thread if one was not already allocated before this method is called, so to execute select statements that begin a transaction (such as "select for update"
), execute DatasourcePool::beginTransaction() first to ensure that the connection is dedicated to the calling thread.
sql | The SQL command to execute on the server |
... | Include any values to be bound (using %v in the command string) or placeholder specifications (using : key_name in the command string) in order after the command string |
Implements Qore::SQL::AbstractDatasource.
Qore::SQL::DatasourcePool::setErrorTimeout | ( | timeout | ts | ) |
Sets the timeout period for waiting for a connection to come free; note that timeout values less than or equal to zero mean that requests for a connection will wait indefinitely.
nothing Qore::SQL::DatasourcePool::setEventQueue | ( | Qore::Thread::Queue | queue, |
auto | arg | ||
) |
Sets a queue object for DBI events on the pool.
queue | the Queue object to receive datasource events; note that the Queue passed cannot have any maximum size set or a QUEUE-ERROR will be thrown; passing NOTHING will clear any event queue |
arg | an argument to be included in the arg key of datasource events |
QUEUE-ERROR | the Queue passed has a maximum size set |
Qore::SQL::DatasourcePool::setWarningCallback | ( | timeout | ms, |
code | callback, | ||
auto | arg | ||
) |
sets a connection delay warning callback to be called any time the delay assigning a connection from the pool exceeds the given timeout in milliseconds
ms | the period of time with a resolution of milliseconds after which the callback will be called if a connection cannot be allocated in the given time period |
callback | a closure or call reference taking three or four arguments: (string desc, int time, int warning_timeout[, any arg]) which will be passed a datasource description string for the pool, an integer giving the amount of time it took to acquire the connection in microseconds (divide by 1000 to get milliseconds), an integer giving the warning timeout threshold in milliseconds, and optionally the arg value passed to this method |
arg | an optional argument that will be passed to the warning callback |
string Qore::SQL::DatasourcePool::toString | ( | ) |
Returns a string with technical information about the object.
|
virtual |
Allocates a persistent connection to the current thread from the pool (if one has not already been allocated) and executes SQL code on the DB connection, taking a list for all bind arguments.
Same as DatasourcePool::exec() except takes an explicit list for bind arguments
This method also accepts all bind parameters (%d
, %v
, %s
, etc) as documented in Binding by Value and Placeholder
sql | The SQL command to execute on the server |
vargs | Include any values to be bound (using %v in the command string) or placeholder specifications (using : key_name in the command string) in order after the command string |
Implements Qore::SQL::AbstractDatasource.
|
virtual |
Executes a select statement on the server and returns the results in a hash (column names) of lists (column values per row), taking a list for all bind arguments.
The return format of this method is suitable for use with context statements, for easy iteration and processing of query results. Alternatively, the HashListIterator class can be used to iterate the return value of this method.
This method also accepts all bind parameters (%d
, %v
, %s
, etc) as documented in Binding by Value and Placeholder
This method does not retain the datasource connection for the current thread if one was not already allocated before this method is called, so to execute select statements that begin a transaction (such as "select for update"
), execute DatasourcePool::beginTransaction() first to ensure that the connection is dedicated to the calling thread.
sql | The SQL command to execute on the server |
vargs | Include any values to be bound (using %v in the command string) or placeholder specifications (using : key_name in the command string) in order after the command string |
Implements Qore::SQL::AbstractDatasource.
|
virtual |
Executes a select statement on the server and returns the first row as a hash (column names and values), taking a list for all bind arguments.
This method is the same as the DatasourcePool::selectRow() method, except this method takes a single argument after the SQL command giving the list of bind value parameters
This method also accepts all bind parameters (%d
, %v
, %s
, etc) as documented in Binding by Value and Placeholder
This method does not retain the datasource connection for the current thread if one was not already allocated before this method is called, so to execute select statements that begin a transaction (such as "select for update"
), execute DatasourcePool::beginTransaction() first to ensure that the connection is dedicated to the calling thread.
sql | The SQL command to execute on the server |
vargs | Include any values to be bound (using %v in the command string) or placeholder specifications (using : key_name in the command string) in order after the command string |
Implements Qore::SQL::AbstractDatasource.
|
virtual |
Executes a select statement on the server and returns the results in a list (rows) of hashes (column names and values), taking a list for all bind arguments.
Same as the Datasource::selectRows() method, except this method takes a single argument after the SQL command giving the list of bind value parameters.
The usual return value of this method can be iterated with the ListHashIterator class.
The return format of this method is not as memory efficient as that returned by the DatasourcePool::select() method, therefore for larger amounts of data, it is recommended to use DatasourcePool::select().
This method also accepts all bind parameters (%d
, %v
, %s
, etc) as documented in Binding by Value and Placeholder
This method does not retain the datasource connection for the current thread if one was not already allocated before this method is called, so to execute select statements that begin a transaction (such as "select for update"
), execute DatasourcePool::beginTransaction() first to ensure that the connection is dedicated to the calling thread.
sql | The SQL command to execute on the server |
vargs | Include any values to be bound (using %v in the command string) or placeholder specifications (using : key_name in the command string) in order after the command string |
Implements Qore::SQL::AbstractDatasource.