Note: This class is not available with the PO_NO_DATABASE parse option.
The Datasource class is the high-level Qore interface to Qore's DBI layer, and as such, Datasource objects allow Qore programs to access databases that have a Qore DBI driver. The Datasource class will attempt to load any DBI driver that is not currently loaded in the constructor. For connection pooling support, see the DatasourcePool class.
Datasource objects will implicitly call Datasource::open() if no connection has yet been established and a method is called requiring a connection to the database server. Therefore any method that requires communication with the database server can also throw any exception that the open method can throw.
Some Qore DBI drivers allow "select" queries to be executed through the Datasource::exec() method, and allow SQL commands (procedure calls, etc) to be executed through the Datasource::select() method, and some DBI drivers do not (depends on the underlying DB API). At any rate, the transaction lock is set when auto-commit is disabled and when the Datasource::exec() or Datasource::beginTransaction() methods are executed as documented above. Therefore executing a transaction relevant command through the Datasource::select() method while auto-commit mode is disabled and a transaction has not yet started will not result in the transaction lock being allocated to the current thread and therefore could cause transaction errors when sharing the Datasource object between multiple threads.
Only databases with an existing Qore DBI driver can be accessed through the Qore Datasource class.
All Qore DBI drivers set new connections to use transaction isolation level "read committed".
The Datasource class provides consistent, high-level, per-connection locking on requests at a level above the DBI drivers to ensure that the communication between clients and servers is properly serialized.
All Datasource methods accepting SQL strings to execute understand a special syntax used in the query string to bind Qore data by value and to specify placeholders for output variables (for example, when executing a stored procedure or database function). Placeholder binding is DBI driver specific, but binding by value is supported with the same syntax in all drivers. Additionally, the %d numeric specifier is supported equally in all Qore DBI drivers.
Table 4.538. Datasource Format Specifiers
Format Specification | Description |
|---|---|
| If any value other than NOTHING or NULL is given, then the value is converted to an integer and this value is substituted in the string at this position; if the value is NOTHING or NULL, then a literal 'null' is substituted instead. |
| The argument is converted to a string and the string is inserted literally without any conversion or escape sequences in the string; this is useful for table or schema prefixes, etc |
| The argument is bound by value according to the DBI driver's implementation. |
To bind qore data values directly in a binary format in an SQL command, use %v in the command string, and include the value as an argument after the string. Binding by value means that Qore's DBI driver will take care of formatting the data properly for use in the query with the database server. That means that strings do not need to be quoted, date/time values do not need special formatting, binary object (with BLOB columns, for example) can be used directly in queries, etc.
Here is an example:
$rows = $pool.exec("insert into table (varchar_col, timestamp_col, blob_col, numeric_col)
values (%v, %v, %v, %d)", $string, now(), $binary, 100);
To insert a numeric value or a literal 'null' in a query, use %d in the command string, and include the value as an argument after the string. If the value is NOTHING or NULL, a literal 'null' will be written to the string; otherwise the argument is converted to a floating-point value or integer if necessary and written to the string. This is useful for working with DECIMAL (NUMERIC, NUMBER) types in a database-independent way; for example PostgreSQL servers do not do type conversions to DECIMAL types when a string, integer, or float is bound by value, therefore to ensure that integral decimal values can be used in a database-independent way (with 'null' substitution when no value is bound), it's best to use the %d code in the command string instead of %v.
For binding placeholders for output variables, write a unique name in the string and prefix it with a colon (ex: :code). In this case the method will return a hash of the output variables using the placeholder names as keys, but without the colon prefix. By default, a string type will be bound to the position. To bind other variable types to placeholder positions, include the type constant (see Type Constants) as an argument after the command string. For BLOBs, use Binary, for CLOBs, use the string "clob" (constants will be provided in a future release). Not all DBI drivers require placeholder buffer specifications; see the documentation for the DBI driver in question for more information and examples regarding placeholder buffer specifications.
Datasource objects have an internal transaction lock which will be grabbed when the Datasource::exec(), Datasource::vexec() Datasource::execRaw(), or Datasource::beginTransaction() methods are executed and autocommit is not enabled. This enables a single datasource to be safely used for transaction management by several threads simultaneously. Note that an exception in a Datasource method that would acquire the lock (such as the Datasource::exec() method) when it's not already held, will have the effect that the transaction lock is not acquired.
Any thread attempting to do transaction-relevant actions on a Datasource with auto-commit disabled while a transaction is in progress by another thread will block until the thread currently executing a transaction executes the Datasource::commit() or Datasource::rollback() methods (or the Datasource is deleted, reset, or closed, in which case the lock is released and an exception is raised as well).
There is a timeout associated with the transaction lock; if a thread waits for the transaction lock for more than the timeout period, then an exception will be raised in the waiting thread. The timeout value can be read and changed with the Datasource::getTransactionLockTimeout() and Datasource::setTransactionLockTimeout() methods, respectively. The default transaction lock timeout value is 120 seconds.
Table 4.539. SQL::Datasource Method Overview
Method | Except? | Description |
|---|---|---|
|
| Y | Creates the Datasource object; attempts to load a DBI driver if the driver is not already present in Qore. |
Y | Destroys the object. | |
N | Creates a new Datasource object with the same driver as the original and copies of all the connection parameters. | |
|
| Y | Opens a connection to a database; an exception is thrown if any errors occur. |
|
| N | Closes the connection to the database; an exception is thrown if any errors occur. |
|
| Y | Commits the transaction and releases the transaction lock; an exception is thrown if any errors occur. |
|
| Y | Rolls back the transaction and releases the transaction lock; an exception is thrown if any errors occur. |
|
| N | Turns autocommit on or off for this object. |
|
| Y | Executes SQL code on the DB connection. |
|
| Y | Executes SQL code (like Datasource::exec()) on the DB connection without any variable binding. |
|
| Y | Executes SQL code on the DB connection, taking a list for all bind arguments. |
|
| Y | Executes a select statement on the server and returns the results in a hash (column names) of lists (rows). |
|
| 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. |
|
| Y | Executes a select statement on the server and returns the first row as a hash (column names and values). |
|
| 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. |
|
| Y | Executes a select statement on the server and returns the results in a list (rows) of hashes (column names and values). |
|
| 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. |
|
| Y | Manually grabs the transaction lock |
|
| N | Sets the username parameter for the next open. |
|
| N | Returns the username parameter as a string or NOTHING if none is set. |
|
| N | Sets the password parameter for the next open. |
|
| N | Returns the password parameter as a string or NOTHING if none is set. |
|
| N | Sets the DB name parameter for the next open. |
|
| N | Returns the dbname parameter as a string or NOTHING if none is set. |
|
| N | Sets the charset (encoding) parameter for the next open. |
|
| N | Returns the DBI driver specific charset name for the current connection as a string or NOTHING if none is set. |
|
| N | Returns the Qore charset name for the current connection as a string or |
|
| N | Sets the hostname parameter for the next open. |
|
| N | Returns the hostname parameter as a string or NOTHING if none is set. |
|
| N | Sets the port parameter for the next open. |
|
| N | Returns the port parameter as an int or NOTHING if none is set. |
|
| N | Returns the name of the driver used for the object. |
|
| N | Sets the transaction lock timeout value in milliseconds. Set to 0 for no timeout. |
|
| N | Retrieves the transaction lock timeout value as an integer in milliseconds. |
|
| Y | Returns the driver-specific server version data for the current connection. |
|
| Y | Returns the driver-specific client library version data. Not implemented by all drivers. |
|
| N | Returns |
Creates a Datasource object. The constructor variant taking separate arguments requires the datasource type as the first argument, while most other parameters are optional.
Datasource::constructor(string $driver, string $user = "", string $pass = "", string $dbname = "", string $encoding = "", string $host = "", softint $port = 0)
Datasource::constructor(hash $params)
my Datasource $db(DSPGSQL, "user", "pass", "database", "utf8", "localhost", 5432);
Table 4.540. Arguments for Datasource::constructor(string $driver, string $user = "", string $pass = "", $dbname = "", string $encoding = "", string $host = "", softint $port = 0) Variant
Argument | Description |
|---|---|
| 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. |
| The user name for the new connection. Also see Datasource::setUserName() for a method that allows this parameter to be set after the constructor. |
| The password for the new connection. Also see Datasource::setPassword() for a method that allows this parameter to be set after the constructor. |
| The database name for the new connection. Also see Datasource::setDBName() for a method that allows this parameter to be set after the constructor. |
| 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. |
| The host name for the new connection. Also see Datasource::setHostName() for a method that allows this parameter to be set after the constructor. |
| The port number for the new connection. Also see Datasource::setPort() for a method that allows this parameter to be set after the constructor. |
Table 4.541. Arguments for Datasource::constructor(hash $params) Variant
Argument | Description |
|---|---|
| A hash of parameters for the Datasource; see Datasource Constructor Hash for more information. |
Table 4.542. Datasource Constructor Hash
Key | Type | Description |
|---|---|---|
| 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. | |
| The user name for the new connection. Also see Datasource::setUserName() for a method that allows this parameter to be set after the constructor. | |
| The password for the new connection. Also see Datasource::setPassword() for a method that allows this parameter to be set after the constructor. | |
| The database name for the new connection. Also see Datasource::setDBName() for a method that allows this parameter to be set after the constructor. | |
| 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. | |
| The host name for the new connection. Also see Datasource::setHostName() for a method that allows this parameter to be set after the constructor. | |
| 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. |
Table 4.543. Exceptions Thrown by Datasource::constructor()
err | desc |
|---|---|
| Missing DBI driver identifier as first argument. |
| Could not load a driver for the database identified. |
Closes the datasource if it's open (if any operations are in progress, will block until the operations complete) and destroys the object.
delete $db;
Table 4.544. Exceptions Thrown by Datasource::destructor()
err | desc |
|---|---|
| The Datasource was destroyed while a transaction was still in progress; the transaction will be automatically rolled back. |
Creates a new Datasource object with the same driver as the original and copies of all the connection parameters.
my Datasource $new_ds = $ds.copy();
Manually grabs the transaction lock. This method should be called when the Datasource object will be shared between more than 1 thread, and a transaction will be started with a Datasource::select() method.
Datasource::beginTransaction() returns nothing
$db.beginTransaction();
Table 4.545. Exceptions Thrown by Datasource::beginTransaction()
err | desc |
|---|---|
| Cannot start a transaction when autocommit is enabled. |
| Timeout trying to acquire the transaction lock. |
Opens a connection to the datasouce, using the connection parameters already set. If any errors are encountered, an exception is raised.
Datasource::open() returns nothing
$db.open();
Table 4.546. Exceptions Thrown by Datasource::open()
err | desc |
|---|---|
depends on DBI driver | See documentation for the DBI driver for driver-specific exceptions. |
Closes the connection to the database. If any actions are in progress on the database, the close call will block until the actions complete. If any errors are encountered, an exception is raised.
Datasource::close() returns nothing
$db.close();
Commits the current transaction and releases the transaction lock.
Datasource::commit() returns nothing
$db.commit();
Table 4.547. Exceptions Thrown by Datasource::commit()
err | desc |
|---|---|
| Timeout trying to acquire the transaction lock. |
depends on DBI driver | See documentation for the DBI driver for driver-specific exceptions. |
Returns True if the Datasource is currently in a transaction (has the transaction lock allocated to the calling thread), False if not.
Datasource::inTransaction() returns bool
my bool $is_trans = $db.inTransaction();
Table 4.548. Return Value for Datasource::inTransaction()
Return Type | Description |
|---|---|
Returns |
Rolls back the current transaction and releases the transaction lock.
Datasource::rollback() returns nothing
$db.rollback();
Table 4.549. Exceptions Thrown by Datasource::rollback()
err | desc |
|---|---|
| Timeout trying to acquire the transaction lock. |
depends on DBI driver | See documentation for the DBI driver for driver-specific exceptions. |
Turns autocommit on or off for this object.
Datasource::setAutoCommit(softbool $b = True) returns nothing
$db.setAutoCommit(False);
Table 4.550. Arguments for Datasource::setAutoCommit()
Argument | Description |
|---|---|
| True to turn on autocommit (a commit will be executed after every Datasource::exec()), |
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).
Datasource::exec(string $sql, ...) returns any
Datasource::exec() returns nothing (RT_NOOP)
$rows = $db.exec("insert into table (varchar_col, timestamp_col, blob_col, numeric_col)
values (%v, %v, %v, %d)", $string, now(), $binary, 100);
Table 4.551. Arguments for Datasource::exec()
Argument | Description |
|---|---|
| The SQL command to execute on the server. |
| Include any values to be bound (using |
Table 4.552. Return Values for Datasource::exec()
Return Type | Description |
|---|---|
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.553. Exceptions Thrown by Datasource::exec()
err | desc |
|---|---|
| Timeout trying to acquire the transaction lock. |
depends on DBI driver | See documentation for the DBI driver for driver-specific exceptions. |
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.
Using this method for OLTP statements can affect the application performance. See used DB server documentation for variable binding.
Datasource::execRaw(string $sql) returns any
$rows = $db.exec("create table my_tab (id number, some_text varchar2(30))");
Table 4.554. Arguments for Datasource::execRaw()
Argument | Description |
|---|---|
| The SQL command to execute on the server. |
Table 4.556. Exceptions Thrown by Datasource::execRaw()
err | desc |
|---|---|
| Timeout trying to acquire the transaction lock. |
depends on DBI driver | See documentation for the DBI driver for driver-specific exceptions. |
Same as the Datasource::exec() method, except this method takes a single argument after the SQL command giving the list of bind parameters.
Datasource::vexec(string $sql, list $args) returns any
Datasource::vexec(string $sql) returns any
Datasource::vexec() returns nothing (RT_NOOP)
$rows = $db.vexec("insert into example_table value (%v, %v, %v)", $arg_list);
Table 4.558. Return Values for Datasource::vexec()
Return Type | Description |
|---|---|
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.559. Exceptions Thrown by Datasource::vexec()
err | desc |
|---|---|
| Timeout trying to acquire the transaction lock. |
depends on DBI driver | See documentation for the DBI driver for driver-specific exceptions. |
Executes an SQL select statement on the server and returns the result as a hash (column names) of lists (rows). This format is suitable for use with context Statements, for easy iteration and processing of query results. Additionally, this format is 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().
Datasource::select(string $sql, ...) returns any
Datasource::select() returns nothing (RT_NOOP)
# bind a string and a date/time value by value in a query
$query = $db.select("select * from table where varchar_column = %v and timestamp_column > %v", $string, 2007-10-11T15:31:26.289);
Table 4.560. Arguments for Datasource::select()
Argument | Description |
|---|---|
| The SQL select command to execute on the server. |
| Include any values to be bound (using |
Table 4.562. Exceptions Thrown by Datasource::select()
err | desc |
|---|---|
depends on DBI driver | See documentation for the DBI driver for driver-specific exceptions. |
Same as the Datasource::select() method, except this method takes a single argument after the SQL command giving the list of bind value parameters.
Datasource::vselect(string $sql, list $args) returns any
Datasource::vselect(string $sql) returns any
Datasource::vselect() returns nothing (RT_NOOP)
$query = $db.vselect("select * from example_table where id = %v and name = %v", $arg_list);
Table 4.565. Exceptions Thrown by Datasource::vselect()
err | desc |
|---|---|
depends on DBI driver | See documentation for the DBI driver for driver-specific exceptions. |
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 Datasource::vselectRow().
This method also accepts all bind parameters (%d, %v, etc) as documented in Datasource Binding.
Datasource::selectRow(string $sql, ...) returns any
Datasource::selectRow() returns nothing (RT_NOOP)
$list = $db.selectRow("select * from example_table");
Table 4.566. Arguments for Datasource::selectRow()
Argument | Description |
|---|---|
| The SQL select command to execute on the server. |
| Include any values to be bound (using |
Table 4.568. Exceptions Thrown by Datasource::selectRow()
err | desc |
|---|---|
depends on DBI driver | See documentation for the DBI driver for driver-specific exceptions. |
Same as the Datasource::selectRow() method, except this method takes a single argument after the SQL command giving the list of bind value parameters.
Datasource::vselectRow(string $sql, list $args) returns any
Datasource::vselectRow(string $sql) returns any
Datasource::vselectRow() returns nothing (RT_NOOP)
$list = $db.vselectRow("select * from example_table where id = %v and name = %v", $arg_list);
Table 4.571. Exceptions Thrown by Datasource::vselectRow()
err | desc |
|---|---|
depends on DBI driver | See documentation for the DBI driver for driver-specific exceptions. |
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 Datasource::select() method, therefore for larger amounts of data, it is recommended to use Datasource::select().
This method also accepts all bind parameters (%d, %v, etc) as documented in Datasource Binding.
Datasource::selectRows(string $sql, ...) returns any
Datasource::selectRows() returns nothing (RT_NOOP)
$list = $db.selectRows("select * from example_table");
Table 4.572. Arguments for Datasource::selectRows()
Argument | Description |
|---|---|
| The SQL select command to execute on the server. |
| Include any values to be bound (using |
Table 4.573. Return Values for Datasource::selectRows()
Return Type | Description |
|---|---|
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.574. Exceptions Thrown by Datasource::selectRows()
err | desc |
|---|---|
depends on DBI driver | See documentation for the DBI driver for driver-specific exceptions. |
Same as the Datasource::selectRows() method, except this method takes a single argument after the SQL command giving the list of bind value parameters.
Datasource::vselectRows(string $sql, list $args) returns any
Datasource::vselectRows(string $sql) returns any
Datasource::vselectRows() returns nothing (RT_NOOP)
$list = $db.vselectRows("select * from example_table where id = %v and name = %v", $arg_list);
Table 4.576. Return Values for Datasource::vselectRows()
Return Type | Description |
|---|---|
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.577. Exceptions Thrown by Datasource::vselectRows()
err | desc |
|---|---|
depends on DBI driver | See documentation for the DBI driver for driver-specific exceptions. |
Sets the transaction lock timeout value in milliseconds; set to 0 for no timeout. Like all Qore functions and methods taking timeout values, a relative time value may be passed instead of an integer to make the timeout units clear (ex: 2500ms for 2.5 seconds).
Datasource::setTransactionLockTimeout(softint $timeout_ms = 0) returns nothing
Datasource::setTransactionLockTimeout(date $timeout) returns nothing
$db.setTransactionLockTimeout(5m); # transaction lock timeout set to 5 minutes
Table 4.578. Arguments for Datasource::setTransactionLockTimeout()
Argument | Description |
|---|---|
The timeout value to set in seconds. For no timeout, set to 0. Like all Qore functions and methods taking timeout values, a relative time value may be passed instead of an integer to make the timeout units clear (ex: |
Retrieves the transaction lock timeout value as an integer in milliseconds.
Datasource::getTransactionLockTimeout() returns int
$int = $db.getTransactionLockTimeout();
Table 4.579. Return Values for Datasource::getTransactionLockTimeout()
Return Type | Description |
|---|---|
The transaction lock timeout value in milliseconds. |
Sets the username to use for the connection. Invalid usernames will cause an exception to be thrown when the connection is opened.
Datasource::setUserName(string $user) returns nothing
Datasource::setUserName() returns nothing (RT_NOOP)
$db.setUserName("user");
Table 4.580. Arguments for Datasource::setUserName()
Argument | Description |
|---|---|
| The username to be used for the connection. |
Retrieves the username parameter for connections to the database.
Datasource::getUserName() returns any
$str = $db.getUserName();
Sets the password to use for the connection. Invalid passwords will cause an exception to be thrown when the connection is opened.
Datasource::setPassword(string $pass) returns nothing
Datasource::setPassword() returns nothing (RT_NOOP)
$db.setPassword("pass");
Table 4.582. Arguments for Datasource::setPassword()
Argument | Description |
|---|---|
| The password name to be used for the connection. |
Retrieves the password connection parameter.
Datasource::getPassword() returns any
$str = $db.getPassword();
Sets the database name to use for the connection. Invalid database names will cause an exception to be thrown when the connection is opened.
Datasource::setDBName(string $db) returns nothing
Datasource::setDBName() returns nothing (RT_NOOP)
$db.setDBName("database");
Table 4.584. Arguments for Datasource::setDBName()
Argument | Description |
|---|---|
| The database name to be used for the connection. |
Retrieves the dbname connection parameter.
Datasource::getDBName() returns any
$str = $db.getDBName();
Sets the database-specific character encoding to use for the connection. Invalid character encoding names will cause an exception to be thrown when the connection is opened.
Datasource::setDBCharset(string $encoding) returns nothing
Datasource::setDBCharset() returns nothing (RT_NOOP)
$db.setDBCharset("ALU32UTF8"); # Oracle UTF-8 encoding equivalent
Table 4.586. Arguments for Datasource::setDBCharset()
Argument | Description |
|---|---|
| The database-specific name for the encoding to be used for the connection. |
Sets the hostname to use for the connection (for DBI drivers that support this parameter, such as the mysql and pgsql, for example). Invalid hostnames will cause an exception to be thrown when the connection is opened.
Datasource::setHostName(string $host) returns nothing
Datasource::setHostName() returns nothing (RT_NOOP)
$db.setHostName("localhost");
Table 4.587. Arguments for Datasource::setHostName()
Argument | Description |
|---|---|
| The hostname to be used for the connection. |
Sets the port number to use for the connection (for DBI drivers that support this parameter, such as the mysql, pgsql, and oracle drivers, for example). Invalid port numbers will cause an exception to be thrown when the connection is opened.
Datasource::setPort(softint $port = 0) returns nothing
$db.setPort(5432);
Table 4.588. Arguments for Datasource::setPort()
Argument | Description |
|---|---|
| The port number to be used for the connection. |
Retrieves the database-specific charset set encoding for the current connection.
Datasource::getDBCharset() returns any
$str = $db.getDBCharset();
Retrieves the Qore charset set encoding for the current connection.
Datasource::getOSCharset() returns string
$str = $db.getOSCharset();
Table 4.590. Return Values for Datasource::getOSCharset()
Return Type | Description |
|---|---|
Retrieves the Qore charset set encoding for the current connection or |
Retrieves the hostname connection parameter.
Datasource::getHostName() returns any
$str = $db.getHostName();
Retrieves the port connection parameter or NOTHING if none is set.
Datasource::getPort() returns any
$port = $db.getPort();
Returns the name of the DBI driver used for this object.
Datasource::getDriverName() returns string
$name = $db.getDriverName();
Table 4.593. Return Values for Datasource::getDriverName()
Return Type | Description |
|---|---|
The name of the database driver used for this object. |
Retrieves the driver-specific server version information for the current connection.
Datasource::getServerVersion() returns any
$data = $db.getServerVersion();
Table 4.594. Return Values for Datasource::getServerVersion()
Return Type | Description |
|---|---|
The return type and value depends on the driver; see the documentation for the DBI driver used for the connection. |
Retrieves the driver-specific client library version information. Not implemented for all drivers.
Datasource::getClientVersion() returns any
$data = $db.getClientVersion();
Table 4.595. Return Values for Datasource::getClientVersion()
Return Type | Description |
|---|---|
The return type and value depends on the driver; see the documentation for the DBI driver used for the connection. |