diff options
| author | Mark Newnham <mark@newnhams.com> | 2021-03-26 17:22:43 -0600 |
|---|---|---|
| committer | Damien Regad <dregad@mantisbt.org> | 2021-08-22 11:16:01 +0200 |
| commit | 650f39dbe329515ad7da1531d91cfc4905785795 (patch) | |
| tree | 9ba9824220fdfeaf0498c0ffef0787c8b6a5ff94 | |
| parent | 4087b3b7b1117b797c1c9d928015beacb3f9d87c (diff) | |
| download | adodb-650f39dbe329515ad7da1531d91cfc4905785795.tar.gz adodb-650f39dbe329515ad7da1531d91cfc4905785795.tar.bz2 adodb-650f39dbe329515ad7da1531d91cfc4905785795.zip | |
Update connecr() methof
- Update docblock
- Implement setConnectionParameter for role, dialect
- Remove pre-php5 code fbird_timefmt
| -rw-r--r-- | drivers/adodb-firebird.inc.php | 99 |
1 files changed, 73 insertions, 26 deletions
diff --git a/drivers/adodb-firebird.inc.php b/drivers/adodb-firebird.inc.php index 25b5113f..51a7dc22 100644 --- a/drivers/adodb-firebird.inc.php +++ b/drivers/adodb-firebird.inc.php @@ -44,15 +44,26 @@ class ADODB_firebird extends ADOConnection { var $hasGenID = true; var $_bindInputArray = true; - var $buffers = 0; - var $dialect = 3; var $sysDate = "cast('TODAY' as timestamp)"; var $sysTimeStamp = "CURRENT_TIMESTAMP"; //"cast('NOW' as timestamp)"; var $ansiOuter = true; var $hasAffectedRows = true; var $poorAffectedRows = false; var $blobEncodeType = 'C'; - var $role = false; + /* + * firebird custom optionally specifies the user role + */ + public $role = false; + /* + * firebird custom optionally specifies the connection buffers + */ + public $buffers = 0; + + /* + * firebird custom optionally specifies database dialect + */ + public $dialect = 3; + var $nameQuote = ''; /// string to use to quote identifiers and names function __construct() @@ -82,13 +93,50 @@ class ADODB_firebird extends ADOConnection { } - - // returns true or false - function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$persist=false) + /** + * Connect to a database. + * + * @todo add: parameter int $port, parameter string $socket + * + * @param string|null $argHostname (Optional) The host to connect to. + * @param string|null $argUsername (Optional) The username to connect as. + * @param string|null $argPassword (Optional) The password to connect with. + * @param string|null $argDatabasename (Optional) The name of the database to start in when connected. + * @param bool $persist (Optional) Whether or not to use a persistent connection. + * + * @return bool|null True if connected successfully, false if connection failed, or null if the mysqli extension + * isn't currently loaded. + */ + public function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$persist=false) { - if (!function_exists('fbird_pconnect')) return null; - if ($argDatabasename) $argHostname .= ':'.$argDatabasename; + if (!function_exists('fbird_pconnect')) + return null; + + if ($argDatabasename) + $argHostname .= ':'.$argDatabasename; + $fn = ($persist) ? 'fbird_pconnect':'fbird_connect'; + + /* + * Now merge in the standard connection parameters setting + */ + foreach ($this->connectionParameters as $options) + { + foreach($options as $k=>$v) + { + switch($k){ + case 'role': + $this->role = $v; + break; + case 'dialect': + $this->dialect = $v; + break; + case 'buffers': + $this->buffers = $v; + } + } + } + if ($this->role) $this->_connectionID = $fn($argHostname,$argUsername,$argPassword, $this->charSet,$this->buffers,$this->dialect,$this->role); @@ -96,33 +144,32 @@ class ADODB_firebird extends ADOConnection { $this->_connectionID = $fn($argHostname,$argUsername,$argPassword, $this->charSet,$this->buffers,$this->dialect); - if ($this->dialect != 1) { // http://www.ibphoenix.com/ibp_60_del_id_ds.html - $this->replaceQuote = "''"; + if ($this->dialect == 1) { // http://www.ibphoenix.com/ibp_60_del_id_ds.html + $this->replaceQuote = ""; } if ($this->_connectionID === false) { $this->_handleerror(); return false; } - // PHP5 change. - if (function_exists('fbird_timefmt')) { - fbird_timefmt($this->fbird_datefmt,fbird_DATE ); - if ($this->dialect == 1) { - fbird_timefmt($this->fbird_datefmt,fbird_TIMESTAMP ); - } else { - fbird_timefmt($this->fbird_timestampfmt,fbird_TIMESTAMP ); - } - fbird_timefmt($this->fbird_timefmt,fbird_TIME ); - - } else { - ini_set("ibase.timestampformat", $this->fbird_timestampfmt); - ini_set("ibase.dateformat", $this->fbird_datefmt); - ini_set("ibase.timeformat", $this->fbird_timefmt); - } + ini_set("ibase.timestampformat", $this->fbird_timestampfmt); + ini_set("ibase.dateformat", $this->fbird_datefmt); + ini_set("ibase.timeformat", $this->fbird_timefmt); + return true; } - // returns true or false + /** + * Connect to a database with a persistent connection. + * + * @param string|null $argHostname The host to connect to. + * @param string|null $argUsername The username to connect as. + * @param string|null $argPassword The password to connect with. + * @param string|null $argDatabasename The name of the database to start in when connected. + * + * @return bool|null True if connected successfully, false if connection failed, or null if the mysqli extension + * isn't currently loaded. + */ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,true); |
