| Total Complexity | 3 |
| Total Lines | 66 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | class Pgsql extends SQL |
||
| 6 | { |
||
| 7 | const DEFAULT_HOST = '127.0.0.1'; |
||
| 8 | const DEFAULT_PORT = '5432'; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * @link https://secure.php.net/manual/en/ref.pdo-pgsql.connection.php |
||
| 12 | * @link https://www.postgresql.org/docs/8.3/static/libpq-connect.html |
||
| 13 | * |
||
| 14 | * The PDO_PGSQL Data Source Name (DSN) is composed of the following elements: |
||
| 15 | */ |
||
| 16 | const AVAILABLE_ELEMENTS = [ |
||
| 17 | 'host', |
||
| 18 | 'hostaddr', |
||
| 19 | 'port', |
||
| 20 | 'dbname', |
||
| 21 | |||
| 22 | /** |
||
| 23 | * These two parameters below is not needed, because we can put user/pass |
||
| 24 | * as parameters of PDO class, you can read more by link |
||
| 25 | * @link https://secure.php.net/manual/en/pdo.construct.php |
||
| 26 | */ |
||
| 27 | //'user', |
||
| 28 | //'password', |
||
| 29 | |||
| 30 | 'passfile', |
||
| 31 | 'connect_timeout', |
||
| 32 | 'client_encoding', |
||
| 33 | 'options', |
||
| 34 | 'application_name', |
||
| 35 | 'fallback_application_name', |
||
| 36 | 'keepalives', |
||
| 37 | 'keepalives_idle', |
||
| 38 | 'keepalives_interval', |
||
| 39 | 'keepalives_count', |
||
| 40 | 'tty', |
||
| 41 | 'sslmode', |
||
| 42 | 'requiressl', |
||
| 43 | 'sslcompression', |
||
| 44 | 'sslcert', |
||
| 45 | 'sslkey', |
||
| 46 | 'sslrootcert', |
||
| 47 | 'sslcrl', |
||
| 48 | 'requirepeer', |
||
| 49 | 'krbsrvname', |
||
| 50 | 'gsslib', |
||
| 51 | 'service', |
||
| 52 | 'target_session_attrs' |
||
| 53 | ]; |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Generate DSN by parameters in config |
||
| 57 | * |
||
| 58 | * @param array $config |
||
| 59 | * @return string |
||
| 60 | */ |
||
| 61 | public function genDsn($config): string |
||
| 73 |