From ee0563d1ac6ed2694c48701e24ed7c352edb6639 Mon Sep 17 00:00:00 2001 From: quipo Date: Tue, 19 Mar 2019 12:23:21 +0000 Subject: [PATCH] PHP7 fixes --- MDB2.php | 5 +++-- MDB2/Driver/mysql.php | 3 ++- MDB2/Driver/mysqli.php | 3 ++- MDB2/Driver/pgsql.php | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/MDB2.php b/MDB2.php index db439448..037009c5 100644 --- a/MDB2.php +++ b/MDB2.php @@ -575,7 +575,7 @@ public static function &raiseError($code = null, $dummy3 = false) { $pear = new PEAR; - $err =& $pear->raiseError(null, $code, $mode, $options, $userinfo, 'MDB2_Error', true); + $err = $pear->raiseError(null, $code, $mode, $options, $userinfo, 'MDB2_Error', true); return $err; } @@ -823,7 +823,8 @@ static function parseDSN($dsn) $parsed['dbsyntax'] = $str; } - if (!count($dsn)) { + $dsn = trim($dsn); + if (!strlen($dsn)) { return $parsed; } diff --git a/MDB2/Driver/mysql.php b/MDB2/Driver/mysql.php index beea3e99..628044d8 100644 --- a/MDB2/Driver/mysql.php +++ b/MDB2/Driver/mysql.php @@ -1132,7 +1132,8 @@ function prepare($query, $types = null, $result_types = null, $lobs = array()) } static $prep_statement_counter = 1; - $statement_name = sprintf($this->options['statement_format'], $this->phptype, $prep_statement_counter++ . sha1(microtime() + mt_rand())); + $randomStr = sprintf('%d', $prep_statement_counter++) . sha1(microtime() . sprintf('%d', mt_rand())); + $statement_name = sprintf($this->options['statement_format'], $this->phptype, $randomStr); $statement_name = substr(strtolower($statement_name), 0, $this->options['max_identifiers_length']); $query = "PREPARE $statement_name FROM ".$this->quote($query, 'text'); $statement = $this->_doQuery($query, true, $connection); diff --git a/MDB2/Driver/mysqli.php b/MDB2/Driver/mysqli.php index d955b5a0..3dd9d113 100644 --- a/MDB2/Driver/mysqli.php +++ b/MDB2/Driver/mysqli.php @@ -1151,7 +1151,8 @@ function prepare($query, $types = null, $result_types = null, $lobs = array()) if (!$is_manip) { static $prep_statement_counter = 1; - $statement_name = sprintf($this->options['statement_format'], $this->phptype, $prep_statement_counter++ . sha1(microtime() + mt_rand())); + $randomStr = sprintf('%d', $prep_statement_counter++) . sha1(microtime() . sprintf('%d', mt_rand())); + $statement_name = sprintf($this->options['statement_format'], $this->phptype, $randomStr); $statement_name = substr(strtolower($statement_name), 0, $this->options['max_identifiers_length']); $query = "PREPARE $statement_name FROM ".$this->quote($query, 'text'); diff --git a/MDB2/Driver/pgsql.php b/MDB2/Driver/pgsql.php index 3c0ab4aa..4c329422 100644 --- a/MDB2/Driver/pgsql.php +++ b/MDB2/Driver/pgsql.php @@ -984,7 +984,8 @@ function prepare($query, $types = null, $result_types = null, $lobs = array()) return $connection; } static $prep_statement_counter = 1; - $statement_name = sprintf($this->options['statement_format'], $this->phptype, $prep_statement_counter++ . sha1(microtime() + mt_rand())); + $randomStr = sprintf('%d', $prep_statement_counter++) . sha1(microtime() . sprintf('%d', mt_rand())); + $statement_name = sprintf($this->options['statement_format'], $this->phptype, $randomStr); $statement_name = substr(strtolower($statement_name), 0, $this->options['max_identifiers_length']); if (false === $pgtypes) { $result = @pg_prepare($connection, $statement_name, $query);