Skip to content

Commit

Permalink
PHP7 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
quipo committed Mar 19, 2019
1 parent 792af65 commit ee0563d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions MDB2.php
Expand Up @@ -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;
}

Expand Down Expand Up @@ -823,7 +823,8 @@ static function parseDSN($dsn)
$parsed['dbsyntax'] = $str;
}

if (!count($dsn)) {
$dsn = trim($dsn);
if (!strlen($dsn)) {
return $parsed;
}

Expand Down
3 changes: 2 additions & 1 deletion MDB2/Driver/mysql.php
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion MDB2/Driver/mysqli.php
Expand Up @@ -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');

Expand Down
3 changes: 2 additions & 1 deletion MDB2/Driver/pgsql.php
Expand Up @@ -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);
Expand Down

0 comments on commit ee0563d

Please sign in to comment.