| | |
| | | |
| | | /** |
| | | +-----------------------------------------------------------------------+ |
| | | | program/include/rcube_db_pgsql.php | |
| | | | | |
| | | | This file is part of the Roundcube Webmail client | |
| | | | Copyright (C) 2005-2012, The Roundcube Dev Team | |
| | | | | |
| | |
| | | | PURPOSE: | |
| | | | Database wrapper class that implements PHP PDO functions | |
| | | | for PostgreSQL database | |
| | | | | |
| | | +-----------------------------------------------------------------------+ |
| | | | Author: Aleksander Machniak <alec@alec.pl> | |
| | | +-----------------------------------------------------------------------+ |
| | | */ |
| | | |
| | | |
| | | /** |
| | | * Database independent query interface |
| | |
| | | return isset($this->variables[$varname]) ? $this->variables[$varname] : $default; |
| | | } |
| | | |
| | | /** |
| | | * Returns PDO DSN string from DSN array |
| | | * |
| | | * @param array $dsn DSN parameters |
| | | * |
| | | * @return string DSN string |
| | | */ |
| | | protected function dsn_string($dsn) |
| | | { |
| | | $params = array(); |
| | | $result = 'pgsql:'; |
| | | |
| | | if ($dsn['hostspec']) { |
| | | $params[] = 'host=' . $dsn['hostspec']; |
| | | } |
| | | else if ($dsn['socket']) { |
| | | $params[] = 'host=' . $dsn['socket']; |
| | | } |
| | | |
| | | if ($dsn['port']) { |
| | | $params[] = 'port=' . $dsn['port']; |
| | | } |
| | | |
| | | if ($dsn['database']) { |
| | | $params[] = 'dbname=' . $dsn['database']; |
| | | } |
| | | |
| | | if (!empty($params)) { |
| | | $result .= implode(';', $params); |
| | | } |
| | | |
| | | return $result; |
| | | } |
| | | |
| | | } |