All Classes Namespaces Functions Variables Groups Pages
DBI Functions

## Functions

int | Qore::SQL::dbi_get_driver_capabilities (string driver)
| Returns an integer representing the capabilities of a DBI driver binary-OR'ed together (see DBI Capability Constants) or 0 if the driver is not already loaded.
*list | Qore::SQL::dbi_get_driver_capability_list (string driver)
| Returns a list of each capability supported by the given DBI driver (see DBI Capability Constants) or NOTHING if the driver cannot be found.
*list | Qore::SQL::dbi_get_driver_list ()
| Returns a list of strings of DBI drivers currently loaded or NOTHING if no drivers are loaded.
*hash | Qore::SQL::dbi_get_driver_options (string driver)
| returns a hash of driver options
hash | Qore::SQL::parse_datasource (string ds)
| Returns a datasource hash of the components of a datasource string.

## Detailed Description

These DBI functions were added in Qore 0.8.6; the original functions used camel case names and had NOOP variants (see Old DBI Functions)

# Datasource Hash

Key | Description
`type` | the name of the driver, if present
`user` | the username given in the string
`pass` | the password for the connection
`db` | the database name for the connection
`charset` | The name of the DB-specific character encoding to use for the connection, if present in the string
`host` | the hostname for the connection, if present in the string
`port` | the port number to use for the connection, if present in the string
`options` | A hash of options given in the string, if present. Special options are `"min"` and `"max"`, which are respected by the DatasourcePool::constructor(hash) variant for setting the minimum and maximum connections in the pool, respectively; other options are passed to the DBI driver

## Function Documentation

int Qore::SQL::dbi_get_driver_capabilities | ( | string | driver | ) |

Returns an integer representing the capabilities of a DBI driver binary-OR'ed together (see DBI Capability Constants) or 0 if the driver is not already loaded.

Code Flags:
  CONSTANT

Parameters

  driver | the name of the driver; if the given driver is not already loaded then this function returns NOTHING

Returns
  an integer representing the capabilities of a DBI driver binary-OR'ed together (see DBI Capability Constants) or 0 if the driver is not already loaded

Example:
  my int $caps = dbi_get_driver_capabilities("pgsql");

Note
  similar to getDBIDriverCapabilities() except uses the standard function naming scheme (ie `"names_like_this()"` instead of `"camelCase()"`), always returns an int, and does not have a NOOP variant

Since
  Qore 0.8.6

*list Qore::SQL::dbi_get_driver_capability_list | ( | string | driver | ) |

Returns a list of each capability supported by the given DBI driver (see DBI Capability Constants) or NOTHING if the driver cannot be found.

Code Flags:
  CONSTANT

Parameters

  driver | the name of the driver; if the given driver is not loaded then the function returns NOTHING

Returns
  a list of each capability supported by the given DBI driver (see DBI Capability Constants) or NOTHING if the driver cannot be found

Example:
  my *list $l = dbi_get_driver_capability_list("pgsql");

Note
  similar to getDBIDriverCapabilityList() except uses the standard function naming scheme (ie `"names_like_this()"` instead of `"camelCase()"`) and does not have a NOOP variant

Since
  Qore 0.8.6

*list Qore::SQL::dbi_get_driver_list | ( |  | ) |

Returns a list of strings of DBI drivers currently loaded or NOTHING if no drivers are loaded.

Returns
  a list of strings of DBI drivers currently loaded or NOTHING if no drivers are loaded

Code Flags:
  CONSTANT

Example:
  my *list $l = dbi_get_driver_list();

Note
  similar to getDBIDriverList() except uses the standard function naming scheme (ie `"names_like_this()"` instead of `"camelCase()"`)

Since
  Qore 0.8.6

*hash Qore::SQL::dbi_get_driver_options | ( | string | driver | ) |

returns a hash of driver options

Code Flags:
  CONSTANT

Parameters

  driver | the name of the driver; if the given driver is not already loaded then this function returns NOTHING

Returns
  if the given driver is not already loaded then the function returns NOTHING; if the driver does not support any options then an empty hash is returned, otherwise a hash is returned where the keys are valid option names, and the values are hashes with the following keys:
  - `"desc"`: a string description of the option
  - `"type"`: a string giving the data type restriction for the option

Example:
  my *hash $h = dbi_get_driver_options("pgsql");

Since
  Qore 0.8.6

hash Qore::SQL::parse_datasource | ( | string | ds | ) |

Returns a datasource hash of the components of a datasource string.

Code Flags:
  RET_VALUE_ONLY

Parameters

  ds | a string describing the datasource with the following syntax: `[`driver`:][`user`]:[/`pass`]@`db`[(`charset`)][%`host`[:`port`][{`option`=`val`[,...]}]` where all elements except `@`db are optional

Returns
  a datasource hash of the components of a datasource string

Example:
  my hash $h = parse_datasource("pgsql:user/pass@dbname(utf8)%dbhost.internal:1521{min=4,max=10}");

Exceptions

  DATASOURCE-PARSE-ERROR | a syntax error occurred parsing the datasource string (missing field, unexpected character, etc)

Note
  similar to parseDatasource() except uses the standard function naming scheme (ie `"names_like_this()"` instead of `"camelCase()"`) and does not have a NOOP variant

Since
  Qore 0.8.6