4.16. SQL::DatasourcePool Class

Note: This class is not available with the PO_NO_DATABASE parse option.

The DatasourcePool class provides transparent per-thread, per-transaction Datasource connection pooling.

In most cases, the DatasourcePool class can be used as a drop-in replacement for the Datasource class with autocommit disabled; when a transaction begins, a datasource will be automatically assigned to the calling thread, and it will only be released when a commit or rollback is called on the object. If no Datasource is available, the calling thread will block until a Datasource comes available.

Note that the same principles apply to SQL and database driver usage as with the Datasource class, see the Datasource class documentation for more information.

The DatasourcePool class uses Qore's thread resource tracking infrastructure to raise an exception if a thread terminates while a connection is allocated to it. If Qore user code enters a transaction with a DatasourcePool object and the thread terminates without closing the transaction (via DatasourcePool::commit() or DatasourcePool::rollback()), an exception will automatically be raised, the transaction will be rolled back, and the Datasource connection will be freed to the pool.

4.16.1. DatasourcePool Connection Allocations

The following methods allocate a persistent connection to the calling thread: DatasourcePool::exec(), DatasourcePool::vexec(), DatasourcePool::execRaw(), and DatasourcePool::beginTransaction(). The connection is released to the pool when DatasourcePool::commit() or DatasourcePool::rollback() are called (or in the case the thread terminates, in which case an exception is raised as well).

To begin a transaction with one of the select methods (for example, with "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.

Executing a DatasourcePool method while not in a transaction is realized by allocating a temporary connection to the calling thread which is re-released when the method returns. No explicit commits are executed by the class, therefore it is an error to execute transaction-relevant commands without first calling DatasourcePool::exec(), DatasourcePool::vexec(), DatasourcePool::execRaw(), or DatasourcePool::beginTransaction().

Note that the SQLStatement class also grabs allocates a persistent connection to the calling thread when executing if it is created using a DatasourcePool object in the constructor; for more information see the SQLStatement class.

Table 4.630. DatasourcePool Method Overview

Method

Except?

Description

DatasourcePool::constructor(string$driver, string$user = "", string$pass = "", string$dbname = "", string$encoding = "", string$host = "", softint$min = DP_MIN, softint$max = DP_MAX, softint$port = 0)

DatasourcePool::constructor()

Y

Creates the DatasourcePool object; attempts to load a DBI driver if the driver is not already present in Qore.

DatasourcePool::destructor()

Y

Destroys the object.

DatasourcePool::copy()

Y

Throws an exception; currently DatasourcePool objects may not be copied.

nothingDatasourcePool::commit()

Y

Commits the transaction and releases the connection to the pool.

nothingDatasourcePool::rollback()

Y

Rolls back the transaction and releases the connection to the pool.

anyDatasourcePool::exec(string$sql, ...)

nothingDatasourcePool::exec() (RT_NOOP)

Y

Executes SQL code on the DB connection and dedicates a connection to the calling thread.

anyDatasourcePool::execRaw(string$sql)

Y

Executes SQL code (like DatasourcePool::exec()) on the DB connection without any variable binding and dedicates a connection to the calling thread.

anyDatasourcePool::vexec(string$sql, list$args)

anyDatasourcePool::vexec(string$sql)

nothingDatasourcePool::vexec() (RT_NOOP)

Y

Executes SQL code on the DB connection, taking a list for all bind arguments. Dedicates a connection to the calling thread.

anyDatasourcePool::select(string$sql, ...)

nothingDatasourcePool::select() (RT_NOOP)

Y

Executes a select statement on the server and returns the results in a hash (column names) of lists (rows).

anyDatasourcePool::vselect(string$sql, list$args)

anyDatasourcePool::vselect(string$sql)

nothingDatasourcePool::vselect() (RT_NOOP)

Y

Executes a select statement on the server and returns the results in a hash (column names) of lists (rows), taking a list for all bind arguments.

anyDatasourcePool::selectRow(string$sql, ...)

nothingDatasourcePool::selectRow() (RT_NOOP)

Y

Executes a select statement on the server and returns the first row as a hash (column names and values).

anyDatasourcePool::vselectRow(string$sql, list$args)

anyDatasourcePool::vselectRow(string$sql)

nothingDatasourcePool::vselectRow() (RT_NOOP)

Y

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.

anyDatasourcePool::selectRows(string$sql, ...)

nothingDatasourcePool::selectRows() (RT_NOOP)

Y

Executes a select statement on the server and returns the results in a list (rows) of hashes (column names and values).

anyDatasourcePool::vselectRows(string$sql, list$args)

anyDatasourcePool::vselectRows(string$sql)

nothingDatasourcePool::vselectRows() (RT_NOOP)

Y

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.

nothingDatasourcePool::beginTransaction()

Y

Manually allocates a persistent connection to the calling thread.

*stringDatasourcePool::getUserName()

N

Returns the username parameter as a string or NOTHING if none is set.

*stringDatasourcePool::getPassword()

N

Returns the password parameter as a string or NOTHING if none is set.

*stringDatasourcePool::getDBName()

N

Returns the dbname parameter as a string or NOTHING if none is set.

*stringDatasourcePool::getDBCharset()

N

Returns the DBI driver specific charset name for the current connection as a string or NOTHING if none is set.

*stringDatasourcePool::getOSCharset()

N

Returns the Qore charset name for the current connection as a string or NOTHING if none is set.

*stringDatasourcePool::getHostName()

N

Returns the hostname parameter as a string or NOTHING if none is set.

*intDatasourcePool::getPort()

N

Returns the port parameter as an integer or NOTHING if none is set.

stringDatasourcePool::getDriverName()

N

Returns the name of the database driver used for this object as a string.

anyDatasourcePool::getServerVersion()

Y

Returns the driver-specific server version data for the current connection.

anyDatasourcePool::getClientVersion()

Y

Returns the driver-specific client library version data. Not implemented by all drivers.

boolDatasourcePool::inTransaction()

N

Returns True if a transaction is in progress (and therefore a Datasource form the pool is dedicated to the calling thread), False if not.


4.16.2. DatasourcePool::constructor()

Synopsis

Creates a DatasourcePool object. The constructor taking separate arguments requires the database driver name as the first argument, and normally the dbname; the port number is supplied as the final parameter because support for the port number as a connection parameter was added after this class was already present in Qore. The constructor variant taking a hash accepts a hash as produced from parseDatasource().

Prototype

DatasourcePool::constructor(string$driver, string$user = "", string$pass = "", string$dbname = "", string$encoding = "", string$host = "", softint$min = DP_MIN, softint$max = DP_MAX, softint$port = 0)

Example
# open a Datasource pool to a PostgreSQL database, username="user", password="pass", dbname="database"
# use "utf8" for the character encoding for the connection, hostname="localhost", port=5432
# minimum 5 connections (opened immediately), with a maximum of 20
my DatasourcePool $pool(DSPGSQL, "user", "pass", "database", "utf8", "localhost", 5, 20, 5432);
# same as above but using a hash argument with parseDatasource()my DatasourcePool $pool(parseDatasource("pgsql:user/pass@database(utf8)%localhost:5432{min=5,max=20}"));

Table 4.631. Arguments for DatasourcePool::constructor(string $driver, string $user = "", string $pass = "", $dbname = "", string $encoding = "", string $host = "", softint $min = DP_MIN, softint $max = DP_MAX, softint $port = 0) Variant

Argument

Description

string$driver

The name of the DBI driver for the DatasourcePool. See SQL Constants for builtin constants for DBI drivers shipped with Qore, or see the DBI driver documentation to use an add-on driver.

string$user = ""

The user name for the new pool.

string$pass = ""

The password for the new pool.

string$dbname = ""

The database name for the new pool.

string$encoding = ""

The database-specific name of the character encoding to use for the new pool. If no value is passed for this parameter, then the database character encoding corresponding to the default character encoding for the Qore process will be used instead.

string$host = ""

The host name for the new pool.

softint$min = DP_MIN

The minimum number of connections for the new pool; this number of connections will be opened immediately when the pool is created.

softint$max = DP_MAX

The maximum number of connections for the new pool; must be greater than or equal to $min.

softint$port = 0

The port number for the new pool.


Table 4.632. Arguments for DatasourcePool::constructor(hash $params) Variant

Argument

Description

hashparams

A hash of parameters for the DatasourcePool; see DatasourcePool Constructor Hash for more information.


Table 4.633. DatasourcePool Constructor Hash

Key

Type

Description

type

string

The name of the database driver to use; this key is mandatory; if not present, an exception will be raised. See SQL Constants for builtin constants for DBI drivers shipped with Qore, or see the DBI driver documentation to use an add-on driver.

user

string

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

string

The password for the new connection. Also see Datasource::setPassword() for a method that allows this parameter to be set after the constructor.

db

string

The database name for the new connection. Also see Datasource::setDBName() for a method that allows this parameter to be set after the constructor.

charset

string

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 for the Qore process will be used instead.

host

string

The host name for the new connection. Also see Datasource::setHostName() for a method that allows this parameter to be set after the constructor.

port

softint

The port number for the new connection. Also see Datasource::setPort() for a method that allows this parameter to be set after the constructor. If this key is present and is 0 then an exception will be raised.

options

hash

A hash where the min and max options may be given, giving the minimum and maximum connections for the pool. min must be greater than zero, and max must be greater than or equal to min. If min is not present, DP_MIN is assumed; if max is not present, DP_MAX is assumed.


Table 4.634. Exceptions Thrown by DatasourcePool::constructor()

err

desc

DATASOURCEPOOL-PARAM-EEROR

Missing DBI driver, negative number of connections specified, or max < min.

DATASOURCEPOOL-UNSUPPORTED-DATABASE

Could not load a driver for the database identified.


4.16.3. DatasourcePool::destructor()

Synopsis

Throws an exception if any transactions are in progress and returns immediately. The object is destroyed after any in-progress requests are completed.

Example
delete $pool;

Table 4.635. Exceptions Thrown by DatasourcePool::destructor()

err

desc

DATASOURCEPOOL-ERROR

The destructor was called while a transaction was still in progress.


4.16.4. DatasourcePool::copy()

Synopsis

Thows an exception; DatasourcePool objects cannot be copied at the moment.

4.16.5. DatasourcePool::beginTransaction()

Synopsis

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 vselect*, etc).

Prototype

nothingDatasourcePool::beginTransaction()

Example
$pool.beginTransaction();

4.16.6. DatasourcePool::commit()

Synopsis

Commits the current transaction and releases the connection to the pool.

Prototype

nothingDatasourcePool::commit()

Example
$pool.commit();

Table 4.636. Exceptions Thrown by DatasourcePool::commit()

err

desc

depends on DBI driver

See documentation for the DBI driver for driver-specific exceptions.


4.16.7. DatasourcePool::inTransaction()

Synopsis

Returns True if there is a Datasource from the pool currently allocated to the calling thread, False if not.

Prototype

boolDatasourcePool::inTransaction()

Example
my bool $in_trans = $pool.inTransaction();

Table 4.637. Return Value for DatasourcePool::inTransaction()

Return Type

Description

bool

Returns True if there is a Datasource from the pool currently allocated to the calling thread, False if not.


4.16.8. DatasourcePool::rollback()

Synopsis

Rolls back the current transaction and releases the connection to the pool.

Prototype

nothingDatasourcePool::rollback()

Example
$pool.rollback();

Table 4.638. Exceptions Thrown by DatasourcePool::rollback()

err

desc

depends on DBI driver

See documentation for the DBI driver for driver-specific exceptions.


4.16.9. DatasourcePool::exec()

Synopsis

Allocates a persistent connection to the calling thread, 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 takes a special syntax for binding values and placeholders; see the Datasource::exec() method for more information.

Prototype

anyDatasourcePool::exec(string$sql, ...)

nothingDatasourcePool::exec() (RT_NOOP)

Example
$rows = $pool.exec("insert into table (varchar_col, timestamp_col, blob_col, numeric_col)
values (%v, %v, %v, %d)", $string, now(), $binary, 100);

Table 4.639. Arguments for DatasourcePool::exec()

Argument

Description

string$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.


Table 4.640. Return Values for DatasourcePool::exec()

Return Type

Description

any

The return value depends on the DBI driver; normally, for commands with placeholders, a hash is returned holding the values acquired from executing the SQL statement. For all other commands, normally an int row count is returned. However, some DBI drivers also allow select statements to be executed through this interface, which would also return a hash of list.


Table 4.641. Exceptions Thrown by DatasourcePool::exec()

err

desc

depends on DBI driver

See documentation for the DBI driver for driver-specific exceptions.


4.16.10. DatasourcePool::execRaw()

Synopsis

Grabs the transaction lock (if autocommit is disabled) 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.

Warning

Using this method for OLTP statements can affect the application performance. See used DB server documentation for variable binding.

Prototype

anyDatasourcePool::execRaw(string$sql)

Example
$rows = $pool.execRaw("create table my_tab (id number, some_text varchar2(30))");

Table 4.642. Arguments for DatasourcePool::execRaw()

Argument

Description

string$sql

The SQL command to execute on the server.


Table 4.643. Return Values for DatasourcePool::execRaw()

Return Type

Description

any

The return value depends on the DBI driver; normally an int row count is returned. However, some DBI drivers also allow select statements to be executed through this interface, which would also return a hash of list.


Table 4.644. Exceptions Thrown by DatasourcePool::execRaw()

err

desc

TRANSACTION-LOCK-TIMEOUT

Timeout trying to acquire the transaction lock.

depends on DBI driver

See documentation for the DBI driver for driver-specific exceptions.


4.16.11. DatasourcePool::vexec()

Synopsis

Same as the DatasourcePool::exec() method, except this method takes a single argument after the SQL command giving the list of bind parameters.

This method allocates a persistent connection from the pool to the calling thread.

Prototype

anyDatasourcePool::vexec(string$sql, list$args)

anyDatasourcePool::vexec(string$sql)

nothingDatasourcePool::vexec() (RT_NOOP)

Example
$rows = $pool.vexec("insert into example_table value (%v, %v, %v)", $arg_list);

Table 4.645. Arguments for DatasourcePool::vexec()

Argument

Description

string$sql

The SQL command to execute on the server.

[list$args]

Include any values to be bound (using %v in the command string) or placeholder specifications (using :<key_name> in the command string) in a single optional list in order after the command string.


Table 4.646. Return Values for DatasourcePool::vexec()

Return Type

Description

Integer or Hash

For commands with placeholders, a hash is returned holding the values acquired from executing the SQL statement. For all other commands, a row count is returned.


Table 4.647. Exceptions Thrown by DatasourcePool::vexec()

err

desc

any

The return value depends on the DBI driver; normally, for commands with placeholders, a hash is returned holding the values acquired from executing the SQL statement. For all other commands, normally an int row count is returned. However, some DBI drivers also allow select statements to be executed through this interface, which would also return a hash of list.


4.16.12. DatasourcePool::select()

Synopsis

Executes an SQL select statement on the server and returns the result as a hash (column names) of lists (rows). See Datasource::select() for more information.

Note that this method does not allocate a persistent connection to the calling thread; if the calling thread does not already have a connection allocated to it, a temporary connection will be allocated for executing the select query and returning the results; the temporary connection will be immediately returned to the pool when this method returns. It is an error to execute transaction relevant commands with this method without first allocating a persistent connection with DatasourcePool::exec(), DatasourcePool::vexec(), DatasourcePool::execRaw(), or DatasourcePool::beginTransaction().

Prototype

anyDatasourcePool::select(string$sql, ...)

nothingDatasourcePool::select() (RT_NOOP)

Example
# bind a string and a date/time value by value in a query
$query = $pool.select("select * from table where varchar_column = %v and timestamp_column > %v",
$string, 2007-10-11T15:31:26.289);

Table 4.648. Arguments for DatasourcePool::select()

Argument

Description

string$sql

The SQL select 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.


Table 4.649. Return Values for DatasourcePool::select()

Return Type

Description

any

Normally returns a hash (the keys are the column names) of list (each hash key's value is a list giving the row data), however some DBI drivers allow any SQL to be executed through this method, in which case also int.


Table 4.650. Exceptions Thrown by DatasourcePool::select()

err

desc

depends on DBI driver

See documentation for the DBI driver for driver-specific exceptions.


4.16.13. DatasourcePool::vselect()

Synopsis

Same as the DatasourcePool::select() method, except this method takes a single argument after the SQL command giving the list of bind value parameters.

Note that this method does not allocate a persistent connection to the calling thread; if the calling thread does not already have a connection allocated to it, a temporary connection will be allocated for executing the select query and returning the results; the temporary connection will be immediately returned to the pool when this method returns. It is an error to execute transaction relevant commands with this method without first allocating a persistent connection with DatasourcePool::exec(), DatasourcePool::vexec(), DatasourcePool::execRaw(), or DatasourcePool::beginTransaction().

Prototype

anyDatasourcePool::vselect(string$sql, list$args)

anyDatasourcePool::vselect(string$sql)

nothingDatasourcePool::vselect() (RT_NOOP)

Example
$query = $pool.vselect("select * from example_table where id = %v and name = %v", $arg_list);

Table 4.651. Arguments for DatasourcePool::vselect()

Argument

Description

string$sql

The SQL select statement to execute on the server.

[list$args]

Include any values to be bound (using %v in the command string) or placeholder specifications (using :<key_name> in the command string) in a single optional list in order after the command string.


Table 4.652. Return Values for DatasourcePool::vselect()

Return Type

Description

any

Normally returns a hash (the keys are the column names) of list (each hash key's value is a list giving the row data), however some DBI drivers allow any SQL to be executed through this method, in which case also int.


Table 4.653. Exceptions Thrown by DatasourcePool::vselect()

err

desc

depends on DBI driver

See documentation for the DBI driver for driver-specific exceptions.


4.16.14. DatasourcePool::selectRow()

Synopsis

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 all but the first row are discarded. For a similar method taking a list for all bind arguments, see DatasourcePool::vselectRow().

This method also accepts all bind parameters (%d, %v, etc) as documented in Datasource Binding.

Note that this method does not allocate a persistent connection to the calling thread; if the calling thread does not already have a connection allocated to it, a temporary connection will be allocated for executing the select query and returning the results; the temporary connection will be immediately returned to the pool when this method returns. It is an error to execute transaction relevant commands with this method without first allocating a persistent connection with DatasourcePool::exec(), DatasourcePool::vexec(), DatasourcePool::execRaw(), or DatasourcePool::beginTransaction().

Prototype

anyDatasourcePool::selectRow(string$sql, ...)

nothingDatasourcePool::selectRow() (RT_NOOP)

Example
$list = $pool.selectRow("select * from example_table");

Table 4.654. Arguments for DatasourcePool::selectRow()

Argument

Description

string$sql

The SQL select 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.


Table 4.655. Return Values for DatasourcePool::selectRow()

Return Type

Description

any

Normally returns a hash (the keys are the column names) of row data or nothing if no row is found for the query. However, DBI could return other types (all known drivers at the time of writing this documentation only return *hash).


Table 4.656. Exceptions Thrown by DatasourcePool::selectRow()

err

desc

depends on DBI driver

See documentation for the DBI driver for driver-specific exceptions.


4.16.15. DatasourcePool::vselectRow()

Synopsis

Same as the DatasourcePool::selectRow() method, except this method takes a single argument after the SQL command giving the list of bind value parameters.

Note that this method does not allocate a persistent connection to the calling thread; if the calling thread does not already have a connection allocated to it, a temporary connection will be allocated for executing the select query and returning the results; the temporary connection will be immediately returned to the pool when this method returns. It is an error to execute transaction relevant commands with this method without first allocating a persistent connection with DatasourcePool::exec(), DatasourcePool::vexec(), DatasourcePool::execRaw(), or DatasourcePool::beginTransaction().

Prototype

anyDatasourcePool::vselectRow(string$sql, list$args)

anyDatasourcePool::vselectRow(string$sql)

nothingDatasourcePool::vselectRow() (RT_NOOP)

Example
$list = $pool.vselectRow("select * from example_table where id = %v and name = %v", $arg_list);

Table 4.657. Arguments for DatasourcePool::vselectRow()

Argument

Description

string$sql

The SQL select statement to execute on the server.

[list$args]

Include any values to be bound (using %v in the command string) or placeholder specifications (using :<key_name> in the command string) in a single optional list in order after the command string.


Table 4.658. Return Values for DatasourcePool::vselectRow()

Return Type

Description

any

Normally returns a hash (the keys are the column names) of row data or nothing if no row is found for the query. However, DBI could return other types (all known drivers at the time of writing this documentation only return *hash).


4.16.16. DatasourcePool::selectRows()

Synopsis

Executes an SQL select statement on the server and returns the result as a list (rows) of hashes (the column values). This format is not as 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, etc) as documented in Datasource Binding.

Note that this method does not allocate a persistent connection to the calling thread; if the calling thread does not already have a connection allocated to it, a temporary connection will be allocated for executing the select query and returning the results; the temporary connection will be immediately returned to the pool when this method returns. It is an error to execute transaction relevant commands with this method without first allocating a persistent connection with DatasourcePool::exec(), DatasourcePool::vexec(), DatasourcePool::execRaw(), or DatasourcePool::beginTransaction().

Prototype

anyDatasourcePool::selectRows(string$sql, ...)

nothingDatasourcePool::selectRows() (RT_NOOP)

Example
$list = $pool.selectRows("select * from example_table");

Table 4.659. Arguments for DatasourcePool::selectRows()

Argument

Description

string$sql

The SQL select 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.


Table 4.660. Return Values for DatasourcePool::selectRows()

Return Type

Description

any

Normally returns a list (rows) of hash (where the keys are the column names of each row) or nothing if no rows are found for the query. However, DBI could return other types; for DBI drivers that allow executing generic SQL through this method, any result sets returns should also be in the format list (rows) of hash.


Table 4.661. Exceptions Thrown by DatasourcePool::selectRows()

err

desc

depends on DBI driver

See documentation for the DBI driver for driver-specific exceptions.


4.16.17. DatasourcePool::vselectRows()

Synopsis

Same as the DatasourcePool::selectRows() method, except this method takes a single argument after the SQL command giving the list of bind value parameters.

Note that this method does not allocate a persistent connection to the calling thread; if the calling thread does not already have a connection allocated to it, a temporary connection will be allocated for executing the select query and returning the results; the temporary connection will be immediately returned to the pool when this method returns. It is an error to execute transaction relevant commands with this method without first allocating a persistent connection with DatasourcePool::exec(), DatasourcePool::vexec(), DatasourcePool::execRaw(), or DatasourcePool::beginTransaction().

Prototype

anyDatasourcePool::vselectRows(string$sql, list$args)

anyDatasourcePool::vselectRows(string$sql)

nothingDatasourcePool::vselectRows() (RT_NOOP)

Example
$list = $pool.vselectRows("select * from example_table where id = %v and name = %v", $arg_list);

Table 4.662. Arguments for DatasourcePool::vselectRows()

Argument

Description

string$sql

The SQL select statement to execute on the server.

[list$args]

Include any values to be bound (using %v in the command string) or placeholder specifications (using :<key_name> in the command string) in a single optional list in order after the command string.


Table 4.663. Return Values for DatasourcePool::vselectRows()

Return Type

Description

any

Normally returns a list (rows) of hash (where the keys are the column names of each row) or nothing if no rows are found for the query. However, DBI could return other types; for DBI drivers that allow executing generic SQL through this method, any result sets returns should also be in the format list (rows) of hash.


Table 4.664. Exceptions Thrown by DatasourcePool::vselectRows()

err

desc

depends on DBI driver

See documentation for the DBI driver for driver-specific exceptions.


4.16.18. DatasourcePool::getUserName()

Synopsis

Retrieves the username parameter for all connections in this pool.

Prototype

*stringDatasourcePool::getUserName()

Example
my *string $str = $pool.getUserName();

Table 4.665. Return Values for DatasourcePool::getUserName()

Return Type

Description

*string

The username connection parameter or NOTHING if no value is set.


4.16.19. DatasourcePool::getPassword()

Synopsis

Retrieves the password connection parameter.

Prototype

*stringDatasourcePool::getPassword()

Example
my *string $str = $pool.getPassword();

Table 4.666. Return Values for DatasourcePool::getPassword()

Return Type

Description

*string

Retrieves the password connection parameter or NOTHING if none is set.


4.16.20. DatasourcePool::getDBName()

Synopsis

Retrieves the database name connection parameter if any is set.

Prototype

*stringDatasourcePool::getDBName()

Example
my *string $str = $pool.getDBName();

Table 4.667. Return Values for DatasourcePool::getDBName()

Return Type

Description

*string

Retrieves the password connection parameter or NOTHING if none is set.


4.16.21. DatasourcePool::getDBCharset()

Synopsis

Retrieves the database-specific charset set encoding for the current connection.

Prototype

*stringDatasourcePool::getDBCharset()

Example
my *string $str = $pool.getDBCharset();

Table 4.668. Return Values for DatasourcePool::getDBCharset()

Return Type

Description

*string

Retrieves the database-specific charset set encoding for the current connection or NOTHING if none is set.


4.16.22. DatasourcePool::getOSCharset()

Synopsis

Retrieves the Qore charset set encoding for the current connection.

Prototype

*stringDatasourcePool::getOSCharset()

Example
my *string $str = $pool.getOSCharset();

Table 4.669. Return Values for DatasourcePool::getOSCharset()

Return Type

Description

*string

Retrieves the Qore charset set encoding for the current connection or "unknown" if unknown.


4.16.23. DatasourcePool::getHostName()

Synopsis

Retrieves the hostname connection parameter.

Prototype

*stringDatasourcePool::getHostName()

Example
my *string $str = $pool.getHostName();

Table 4.670. Return Values for DatasourcePool::getHostName()

Return Type

Description

*string

Retrieves the hostname connection parameter or NOTHING if none is set.


4.16.24. DatasourcePool::getPort()

Synopsis

Retrieves the port connection parameter.

Prototype

*intDatasourcePool::getPort()

Example
my *int $port = $pool.getPort();

Table 4.671. Return Values for DatasourcePool::getPort()

Return Type

Description

*int

Retrieves the port connection parameter or no value if no port is set.


4.16.25. DatasourcePool::getDriverName()

Synopsis

Returns the name of the DBI driver used for this object.

Prototype

stringDatasourcePool::getDriverName()

Example
$name = $pool.getDriverName();

Table 4.672. Return Values for DatasourcePool::getDriverName()

Return Type

Description

string

The name of the database driver used for this object.


4.16.26. DatasourcePool::getServerVersion()

Synopsis

Retrieves the driver-specific server version information for the current connection.

Prototype

anyDatasourcePool::getServerVersion()

Example
$data = $pool.getServerVersion();

Table 4.673. Return Values for DatasourcePool::getServerVersion()

Return Type

Description

any

The return type and value depends on the driver; see the documentation for the DBI driver used for the connection.


4.16.27. DatasourcePool::getClientVersion()

Synopsis

Retrieves the driver-specific client library version information. Not implemented for all drivers.

Prototype

anyDatasourcePool::getClientVersion()

Example
$data = $pool.getClientVersion();

Table 4.674. Return Values for DatasourcePool::getClientVersion()

Return Type

Description

any

The return type and value depends on the driver; see the documentation for the DBI driver used for the connection.


There are no comments yet

Leave a Comment



?
? ?
?

 
Powered by TalkBack