Show:

Db.Db Class

Module: Q

The database interface module. Contains basic properties and methods and serves as namespace for more specific sub-classes

Methods

connect

(
  • name
)
Db

This function uses Db to establish a connection with the information stored in the configuration. If the this Db object has already been made, it returns this Db object.

Parameters:

  • name String

    The name of the connection out of the connections added with Db::setConnection

Returns:

Db:

The database connection

getConnection

(
  • name
)
Object | Null

Returns connection details for a connection

Parameters:

Returns:

Object | Null:

getConnections

() Object

Returns all the connections added thus far

Returns:

getShard

(
  • connName
  • [shardName='']
)
Object | Null

Returns modification details for a shard pertaining to a connection

Parameters:

Returns:

Object | Null:

getShards

(
  • connName
)
Object

Returns all the shards added thus far for a connection

Parameters:

Returns:

parseDsnString

(
  • dsn
)
Object

Parses dsn string and convert to object

Parameters:

  • dsn String

    The dsn string for the database

Returns:

Object:

The data extracted from the DSN string

setConnection

(
  • name
  • details
)

Add a database connection with a name

Parameters:

  • name String

    The name under which to store the connection details

  • details Object

    The connection details. Should include the keys: 'dsn', 'username', 'password', 'driver_options'

setShard

(
  • connName
  • shardName
  • modifications
)

Add a named shard under a database connection Can contain the keys "dsn", "username", "password", "driver_options" They are used in constructing the PDO object.

Parameters:

  • connName String

    The name of the connection to which the shard pertains

  • shardName String

    The name under which to store the shard modifications

  • modifications Object

    The shard modifications. Can include the keys: 'dsn', 'host', 'port', 'dbname', 'unix_socket', 'charset', 'username', 'password', 'driver_options',