jDbParameters
in package
allow to normalize & analyse database parameters.
supported parameters in a profile:
- driver: the jdb driver name, or "pdo" to use dbo ("pdo" value is deprecated, use usepdo instead)
- database: the name of the database (for sqlite: path to the sqlite file)
- host: the host of the database
- port: the port of the database
- user & password: credentials to connect to the database
- force_encoding: force the encoding at the connection, using the default encoding of the application
- dsn: dsn (pdo, odbc... optional)
- usepdo: true if pdo should be used
- pdodriver: name of the pdodriver to use. Guessed from dsn
- pdoext: name of the pdo extension to use. Guessed from dsn
- dbtype: type of the database (so it determines the SQL language)
- phpext: name of the php extension to use
- persistent: if true, the connection should be persistent
- extensions: some information about extensions to load (For sqlite for example. optional)
- single_transaction: indicate to execute all queries into a single transaction (pgsql, optional)
- busytimeout: timeout for the connection (sqlite, optional)
- timeout: timeout for the connection (pgsql, optional)
- search_path: schema for pgsql (optional)
- table_prefix: prefix to add to database table. Used by jDao (optional)
Tags
Table of Contents
- $driversInfos : mixed
- informations about correspondance between pdo driver and native driver, type of function etc.
- $JdbDriverIndex : mixed
- $parameters : mixed
- $PDODriverIndex : mixed
- $pdoNeededDsnInfo : mixed
- __construct() : mixed
- the constructor normalizes parameters: it ensure that all parameters needed by jDb and the targeted database type are there, as some parameters can be "guessed" by jDb or needed for internal use.
- getDriversInfosList() : mixed
- getParameters() : mixed
- isExtensionActivated() : mixed
- indicate if the php extension corresponding to the database configuration is available in the current php configuration.
- _checkRequirements() : mixed
- getDatabaseInfo() : array<string|int, mixed>
- it gives the name of the jDb driver and the database type indicated in a profile.
- getPDODsn() : mixed
- normalizeBoolean() : mixed
Properties
$driversInfos
informations about correspondance between pdo driver and native driver, type of function etc.
protected
static mixed
$driversInfos
= array(
//array('database type', 'native extension name', 'pdo extension name', 'jdb driver name', 'pdo driver name')
0 => array('mysql', 'mysqli', 'pdo_mysql', 'mysqli', 'mysql'),
1 => array('mysql', 'mysql', 'pdo_mysql', 'mysql', 'mysql'),
2 => array('pgsql', 'pgsql', 'pdo_pgsql', 'pgsql', 'pgsql'),
// pgsql:host=;port=;dbname=;user=;password=;
3 => array('sqlite', 'sqlite3', 'pdo_sqlite', 'sqlite3', 'sqlite'),
4 => array('sqlite', 'sqlite', 'pdo_sqlite2', 'sqlite', 'sqlite2'),
5 => array('oci', 'oci8', 'pdo_oci', 'oci', 'oci'),
// experimental oci:dbname=tnsname oci://localhost:1521/mydb
6 => array('mssql', 'mssql', 'pdo_dblib', 'mssql', 'mssql'),
// deprecated since PHP 5.3
7 => array('mssql', 'sqlsrv', 'pdo_sqlsrv', 'sqlsrv', 'sqlsrv'),
//mssql 2005+ sqlsrv:Server=localhost,port;Database=
8 => array('sybase', 'sybase', 'pdo_dblib', 'sybase', 'sybase'),
// deprecated
9 => array('sybase', 'sybase_ct', 'pdo_dblib', 'sybase', 'sybase'),
10 => array('odbc', 'odbc', 'pdo_odbc', 'odbc', 'odbc'),
)
..
Tags
$JdbDriverIndex
protected
static mixed
$JdbDriverIndex
= array('mysqli' => 0, 'mysql' => 1, 'pgsql' => 2, 'sqlite3' => 3, 'sqlite' => 4, 'oci' => 5, 'mssql' => 6, 'sqlsrv' => 7, 'sybase' => 9, 'odbc' => 10)
Tags
$parameters
protected
mixed
$parameters
= array()
Tags
$PDODriverIndex
protected
static mixed
$PDODriverIndex
= array('mysql' => 0, 'pgsql' => 2, 'sqlite' => 3, 'sqlite2' => 4, 'oci' => 5, 'sqlsrv' => 7, 'odbc' => 10, 'mssql' => 6, 'sybase' => 8)
Tags
$pdoNeededDsnInfo
protected
static mixed
$pdoNeededDsnInfo
= array('mysql' => array('host', 'database'), 'pgsql' => array(array('host', 'database'), array('service')), 'sqlite' => array('database'), 'sqlite2' => array('database'), 'oci' => array('database'), 'sqlsrv' => array('host', 'database'), 'odbc' => array('dsn'), 'mssql' => array('host', 'database'), 'sybase' => array('host', 'database'))
Tags
Methods
__construct()
the constructor normalizes parameters: it ensure that all parameters needed by jDb and the targeted database type are there, as some parameters can be "guessed" by jDb or needed for internal use.
public
__construct(array<string|int, mixed> $profileParameters) : mixed
Parameters
- $profileParameters : array<string|int, mixed>
-
profile parameters for a jdb connection required keys: driver optional keys: dsn, host, username, password, database,....
Tags
Return values
mixed —getDriversInfosList()
public
static getDriversInfosList() : mixed
Tags
Return values
mixed —getParameters()
public
getParameters() : mixed
Tags
Return values
mixed —isExtensionActivated()
indicate if the php extension corresponding to the database configuration is available in the current php configuration.
public
isExtensionActivated() : mixed
Tags
Return values
mixed —_checkRequirements()
protected
_checkRequirements(mixed $requirements, mixed &$profile) : mixed
Parameters
- $requirements : mixed
- $profile : mixed
Tags
Return values
mixed —getDatabaseInfo()
it gives the name of the jDb driver and the database type indicated in a profile.
protected
getDatabaseInfo(array<string|int, mixed> $profile) : array<string|int, mixed>
(or corresponding to the PDO dsn indicated in the profile).
Parameters
- $profile : array<string|int, mixed>
-
'driver' key is required. It should indicates 'pdo' or a jdb driver. if 'pdo', a 'dsn' key is required.
Tags
Return values
array<string|int, mixed> —['database type', 'native extension name', 'pdo extension name', 'jdb driver name', 'pdo driver name']
getPDODsn()
protected
getPDODsn(mixed $profile) : mixed
Parameters
- $profile : mixed
Tags
Return values
mixed —normalizeBoolean()
protected
normalizeBoolean(mixed &$profile, mixed $param) : mixed
Parameters
- $profile : mixed
- $param : mixed