[PEAR][DB] Import some new commits

Patch submitted by XRevan86

[DB/pgsql.php] Change pg_exec to pg_query
Encouraged by http://php.net/manual/en/function.pg-query.php and enables
improved monitoring by New Relic (https://newrelic.com)
[DB.php] changed count to empty for php7.2
[DB/common.php] change to array cast for php72

From: https://github.com/pear/DB/
Commits: 7d0ddaff, d04a42a5 and ea9fff4a, respectively
This commit is contained in:
Diogo Cordeiro 2019-08-06 02:52:47 +01:00
parent 24d5d200b8
commit de91d28f6f
3 changed files with 16 additions and 13 deletions

View File

@ -660,7 +660,7 @@ class DB
$parsed['dbsyntax'] = $str;
}
if (!strlen($dsn)) {
if (empty($dsn)) {
return $parsed;
}
@ -1503,4 +1503,4 @@ class DB_row
* tab-width: 4
* c-basic-offset: 4
* End:
*/
*/

View File

@ -1319,7 +1319,8 @@ class DB_common extends PEAR
*/
public function &query($query, $params = array())
{
if (sizeof($params) > 0) {
$params = (array)$params;
if (count($params)) {
$sth = $this->prepare($query);
if (DB::isError($sth)) {
return $sth;
@ -1361,7 +1362,8 @@ class DB_common extends PEAR
{
$params = (array)$params;
// modifyLimitQuery() would be nice here, but it causes BC issues
if (sizeof($params) > 0) {
$params = (array)$params;
if (count($params)) {
$sth = $this->prepare($query);
if (DB::isError($sth)) {
return $sth;
@ -1680,7 +1682,8 @@ class DB_common extends PEAR
}
}
if (sizeof($params) > 0) {
$params = (array)$params;
if (count($params)) {
$sth = $this->prepare($query);
if (DB::isError($sth)) {

View File

@ -332,14 +332,14 @@ class DB_pgsql extends DB_common
$query = $this->modifyQuery($query);
if (!$this->autocommit && $ismanip) {
if ($this->transaction_opcount == 0) {
$result = @pg_exec($this->connection, 'begin;');
$result = @pg_query($this->connection, 'begin;');
if (!$result) {
return $this->pgsqlRaiseError();
}
}
$this->transaction_opcount++;
}
$result = @pg_exec($this->connection, $query);
$result = @pg_query($this->connection, $query);
if (!$result) {
return $this->pgsqlRaiseError();
}
@ -737,7 +737,7 @@ class DB_pgsql extends DB_common
if ($this->transaction_opcount > 0) {
// (disabled) hack to shut up error messages from libpq.a
//@fclose(@fopen("php://stderr", "w"));
$result = @pg_exec($this->connection, 'end;');
$result = @pg_query($this->connection, 'end;');
$this->transaction_opcount = 0;
if (!$result) {
return $this->pgsqlRaiseError();
@ -757,7 +757,7 @@ class DB_pgsql extends DB_common
public function rollback()
{
if ($this->transaction_opcount > 0) {
$result = @pg_exec($this->connection, 'abort;');
$result = @pg_query($this->connection, 'abort;');
$this->transaction_opcount = 0;
if (!$result) {
return $this->pgsqlRaiseError();
@ -917,7 +917,7 @@ class DB_pgsql extends DB_common
* Probably received a table name.
* Create a result resource identifier.
*/
$id = @pg_exec($this->connection, "SELECT * FROM $result LIMIT 0");
$id = @pg_query($this->connection, "SELECT * FROM $result LIMIT 0");
$got_string = true;
} elseif (isset($result->result)) {
/*
@ -1011,7 +1011,7 @@ class DB_pgsql extends DB_common
$tableWhere = "tab.relname = '$table_name'";
}
$result = @pg_exec($this->connection, "SELECT f.attnotnull, f.atthasdef
$result = @pg_query($this->connection, "SELECT f.attnotnull, f.atthasdef
FROM $from
WHERE tab.relname = typ.typname
AND typ.typrelid = f.attrelid
@ -1022,7 +1022,7 @@ class DB_pgsql extends DB_common
$flags = ($row[0] == 't') ? 'not_null ' : '';
if ($row[1] == 't') {
$result = @pg_exec($this->connection, "SELECT a.adsrc
$result = @pg_query($this->connection, "SELECT a.adsrc
FROM $from, pg_attrdef a
WHERE tab.relname = typ.typname AND typ.typrelid = f.attrelid
AND f.attrelid = a.adrelid AND f.attname = '$field_name'
@ -1034,7 +1034,7 @@ class DB_pgsql extends DB_common
} else {
$flags = '';
}
$result = @pg_exec($this->connection, "SELECT i.indisunique, i.indisprimary, i.indkey
$result = @pg_query($this->connection, "SELECT i.indisunique, i.indisprimary, i.indkey
FROM $from, pg_index i
WHERE tab.relname = typ.typname
AND typ.typrelid = f.attrelid