summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorReimuHakurei <alex@alexingram.net>2022-05-06 04:41:03 -0500
committerDamien Regad <dregad@mantisbt.org>2022-05-06 13:52:02 +0200
commitb8661ea2678995ec7a0efeb05e1dadcc957194fd (patch)
tree18a067fd5da31b0fda380723d05b23708f987f57 /drivers
parente5b1ee305a7ebc1a93d9993a708d2ad9e4df65c3 (diff)
downloadadodb-b8661ea2678995ec7a0efeb05e1dadcc957194fd.tar.gz
adodb-b8661ea2678995ec7a0efeb05e1dadcc957194fd.tar.bz2
adodb-b8661ea2678995ec7a0efeb05e1dadcc957194fd.zip
pgsql: remove is_resource() checks (PHP 8.1 compat)
Affected_Rows() always returns false on PHP 8.1, because the 'pgsql result' resource has been replaced by the PgSql\Result class [1]. Changes to original contribution: * Adjust PHPDoc for ADODB_postgres64::$_resultid * Fix one more occurrence in the postgres7 driver Fixes #833 [1]: https://www.php.net/manual/en/class.pgsql-result.php Co-authored-by: Damien Regad <dregad@mantisbt.org> (cherry picked from commit e3287d6be5545634a6ccbf868919028991a68791)
Diffstat (limited to 'drivers')
-rw-r--r--drivers/adodb-postgres64.inc.php12
-rw-r--r--drivers/adodb-postgres7.inc.php2
2 files changed, 6 insertions, 8 deletions
diff --git a/drivers/adodb-postgres64.inc.php b/drivers/adodb-postgres64.inc.php
index 525e09d2..290967e7 100644
--- a/drivers/adodb-postgres64.inc.php
+++ b/drivers/adodb-postgres64.inc.php
@@ -26,7 +26,7 @@ class ADODB_postgres64 extends ADOConnection{
var $databaseType = 'postgres64';
var $dataProvider = 'postgres';
var $hasInsertID = true;
- /** @var bool|resource */
+ /** @var PgSql\Connection|resource|false */
var $_resultid = false;
var $concat_operator='||';
var $metaDatabasesSQL = "select datname from pg_database where datname not in ('template0','template1') order by 1";
@@ -155,7 +155,7 @@ class ADODB_postgres64 extends ADOConnection{
*/
protected function _insertID($table = '', $column = '')
{
- if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false;
+ if ($this->_resultid === false) return false;
$oid = pg_last_oid($this->_resultid);
// to really return the id, we need the table and column-name, else we can only return the oid != id
return empty($table) || empty($column) ? $oid : $this->GetOne("SELECT $column FROM $table WHERE oid=".(int)$oid);
@@ -163,7 +163,7 @@ class ADODB_postgres64 extends ADOConnection{
function _affectedrows()
{
- if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false;
+ if ($this->_resultid === false) return false;
return pg_affected_rows($this->_resultid);
}
@@ -844,7 +844,7 @@ class ADODB_postgres64 extends ADOConnection{
}
// check if no data returned, then no need to create real recordset
if ($rez && pg_num_fields($rez) <= 0) {
- if (is_resource($this->_resultid) && get_resource_type($this->_resultid) === 'pgsql result') {
+ if ($this->_resultid !== false) {
pg_free_result($this->_resultid);
}
$this->_resultid = $rez;
@@ -1075,9 +1075,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{
function _close()
{
- if (!is_resource($this->_queryID)
- || get_resource_type($this->_queryID) != 'pgsql result'
- ) {
+ if ($this->_queryID === false) {
return true;
}
return pg_free_result($this->_queryID);
diff --git a/drivers/adodb-postgres7.inc.php b/drivers/adodb-postgres7.inc.php
index ddbe7a6e..b5e63acf 100644
--- a/drivers/adodb-postgres7.inc.php
+++ b/drivers/adodb-postgres7.inc.php
@@ -231,7 +231,7 @@ class ADODB_postgres7 extends ADODB_postgres64 {
}
// check if no data returned, then no need to create real recordset
if ($rez && pg_num_fields($rez) <= 0) {
- if (is_resource($this->_resultid) && get_resource_type($this->_resultid) === 'pgsql result') {
+ if ($this->_resultid !== false) {
pg_free_result($this->_resultid);
}
$this->_resultid = $rez;