diff options
| author | Damien Regad <dregad@mantisbt.org> | 2021-03-13 23:28:01 +0100 |
|---|---|---|
| committer | Damien Regad <dregad@mantisbt.org> | 2021-03-27 11:04:33 +0100 |
| commit | aa208834198c4cf88a5b7c2c4e71029a1f709c4d (patch) | |
| tree | c4670c5f7518a65050f055787bd5fa3b2a1aef72 /drivers | |
| parent | 9927234520fe472362272b338eee41b91a3bf6d8 (diff) | |
| download | adodb-aa208834198c4cf88a5b7c2c4e71029a1f709c4d.tar.gz adodb-aa208834198c4cf88a5b7c2c4e71029a1f709c4d.tar.bz2 adodb-aa208834198c4cf88a5b7c2c4e71029a1f709c4d.zip | |
mysqli: override setConnectionParameter()
Add error handling for $parameter type: since mysqli_options() requires
an integer, the function now fails and returns false (or throws an
exception if enabled) when given a non-numeric value.
Fixes #693
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/adodb-mysqli.inc.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/adodb-mysqli.inc.php b/drivers/adodb-mysqli.inc.php index 51b5d875..b87cd65f 100644 --- a/drivers/adodb-mysqli.inc.php +++ b/drivers/adodb-mysqli.inc.php @@ -98,6 +98,27 @@ class ADODB_mysqli extends ADOConnection { } /** + * Adds a parameter to the connection string. + * + * Parameter must be one of the the constants listed in mysqli_options(). + * @see https://www.php.net/manual/en/mysqli.options.php + * + * @param int $parameter The parameter to set + * @param string $value The value of the parameter + * + * @example, for mssqlnative driver ('CharacterSet','UTF-8') + * @return bool + */ + public function setConnectionParameter($parameter, $value) { + if(!is_numeric($parameter)) { + $this->outp_throw("Invalid connection parameter '$parameter'", __METHOD__); + return false; + } + $this->connectionParameters[$parameter] = $value; + return true; + } + + /** * Connect to a database. * * @todo add: parameter int $port, parameter string $socket |
