Skip to content

Commit

Permalink
Merge pull request #21 from schengawegga/PHP8.2_ready
Browse files Browse the repository at this point in the history
PHP8.2 ready
  • Loading branch information
ashnazg authored Nov 27, 2023
2 parents a2fff24 + e806c36 commit 4efd340
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 88 deletions.
6 changes: 3 additions & 3 deletions DB/ibase.php
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,9 @@ function nextId($seq_name, $ondemand = true)
$repeat = 0;
do {
$this->pushErrorHandling(PEAR_ERROR_RETURN);
$result = $this->query("SELECT GEN_ID(${sqn}, 1) "
$result = $this->query("SELECT GEN_ID({$sqn}, 1) "
. 'FROM RDB$GENERATORS '
. "WHERE RDB\$GENERATOR_NAME='${sqn}'");
. "WHERE RDB\$GENERATOR_NAME='{$sqn}'");
$this->popErrorHandling();
if ($ondemand && DB::isError($result)) {
$repeat = 1;
Expand Down Expand Up @@ -746,7 +746,7 @@ function createSequence($seq_name)
{
$sqn = strtoupper($this->getSequenceName($seq_name));
$this->pushErrorHandling(PEAR_ERROR_RETURN);
$result = $this->query("CREATE GENERATOR ${sqn}");
$result = $this->query("CREATE GENERATOR {$sqn}");
$this->popErrorHandling();

return $result;
Expand Down
4 changes: 2 additions & 2 deletions DB/msql.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ function nextId($seq_name, $ondemand = true)
$repeat = false;
do {
$this->pushErrorHandling(PEAR_ERROR_RETURN);
$result = $this->query("SELECT _seq FROM ${seqname}");
$result = $this->query("SELECT _seq FROM {$seqname}");
$this->popErrorHandling();
if ($ondemand && DB::isError($result) &&
$result->getCode() == DB_ERROR_NOSUCHTABLE) {
Expand Down Expand Up @@ -490,7 +490,7 @@ function createSequence($seq_name)
if (DB::isError($res)) {
return $res;
}
$res = $this->query("CREATE SEQUENCE ON ${seqname}");
$res = $this->query("CREATE SEQUENCE ON {$seqname}");
return $res;
}

Expand Down
2 changes: 2 additions & 0 deletions DB/mssql.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id$
* @link http://pear.php.net/package/DB
* @deprecated since 1.12.0
*/

/**
Expand Down Expand Up @@ -51,6 +52,7 @@
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: @package_version@
* @link http://pear.php.net/package/DB
* @deprecated since 1.12.0
*/
class DB_mssql extends DB_common
{
Expand Down
20 changes: 11 additions & 9 deletions DB/mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id$
* @link http://pear.php.net/package/DB
* @deprecated since 1.12.0
*/

/**
Expand All @@ -43,6 +44,7 @@
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: @package_version@
* @link http://pear.php.net/package/DB
* @deprecated since 1.12.0
*/
class DB_mysql extends DB_common
{
Expand Down Expand Up @@ -590,7 +592,7 @@ function nextId($seq_name, $ondemand = true)
do {
$repeat = 0;
$this->pushErrorHandling(PEAR_ERROR_RETURN);
$result = $this->query("UPDATE ${seqname} ".
$result = $this->query("UPDATE {$seqname} ".
'SET id=LAST_INSERT_ID(id+1)');
$this->popErrorHandling();
if ($result === DB_OK) {
Expand All @@ -602,7 +604,7 @@ function nextId($seq_name, $ondemand = true)
// EMPTY SEQ TABLE
// Sequence table must be empty for some reason, so fill
// it and return 1 and obtain a user-level lock
$result = $this->getOne("SELECT GET_LOCK('${seqname}_lock',10)");
$result = $this->getOne("SELECT GET_LOCK('{$seqname}_lock',10)");
if (DB::isError($result)) {
return $this->raiseError($result);
}
Expand All @@ -612,14 +614,14 @@ function nextId($seq_name, $ondemand = true)
}

// add the default value
$result = $this->query("REPLACE INTO ${seqname} (id) VALUES (0)");
$result = $this->query("REPLACE INTO {$seqname} (id) VALUES (0)");
if (DB::isError($result)) {
return $this->raiseError($result);
}

// Release the lock
$result = $this->getOne('SELECT RELEASE_LOCK('
. "'${seqname}_lock')");
. "'{$seqname}_lock')");
if (DB::isError($result)) {
return $this->raiseError($result);
}
Expand Down Expand Up @@ -699,12 +701,12 @@ function createSequence($seq_name)
return $res;
}
// insert yields value 1, nextId call will generate ID 2
$res = $this->query("INSERT INTO ${seqname} (id) VALUES (0)");
$res = $this->query("INSERT INTO {$seqname} (id) VALUES (0)");
if (DB::isError($res)) {
return $res;
}
// so reset to zero
return $this->query("UPDATE ${seqname} SET id = 0");
return $this->query("UPDATE {$seqname} SET id = 0");
}

// }}}
Expand Down Expand Up @@ -743,7 +745,7 @@ function _BCsequence($seqname)
// Obtain a user-level lock... this will release any previous
// application locks, but unlike LOCK TABLES, it does not abort
// the current transaction and is much less frequently used.
$result = $this->getOne("SELECT GET_LOCK('${seqname}_lock',10)");
$result = $this->getOne("SELECT GET_LOCK('{$seqname}_lock',10)");
if (DB::isError($result)) {
return $result;
}
Expand All @@ -753,7 +755,7 @@ function _BCsequence($seqname)
return $this->mysqlRaiseError(DB_ERROR_NOT_LOCKED);
}

$highest_id = $this->getOne("SELECT MAX(id) FROM ${seqname}");
$highest_id = $this->getOne("SELECT MAX(id) FROM {$seqname}");
if (DB::isError($highest_id)) {
return $highest_id;
}
Expand All @@ -769,7 +771,7 @@ function _BCsequence($seqname)
// If another thread has been waiting for this lock,
// it will go thru the above procedure, but will have no
// real effect
$result = $this->getOne("SELECT RELEASE_LOCK('${seqname}_lock')");
$result = $this->getOne("SELECT RELEASE_LOCK('{$seqname}_lock')");
if (DB::isError($result)) {
return $result;
}
Expand Down
14 changes: 7 additions & 7 deletions DB/mysqli.php
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ function nextId($seq_name, $ondemand = true)
// so fill it and return 1
// Obtain a user-level lock
$result = $this->getOne('SELECT GET_LOCK('
. "'${seqname}_lock', 10)");
. "'{$seqname}_lock', 10)");
if (DB::isError($result)) {
return $this->raiseError($result);
}
Expand All @@ -708,7 +708,7 @@ function nextId($seq_name, $ondemand = true)

// Release the lock
$result = $this->getOne('SELECT RELEASE_LOCK('
. "'${seqname}_lock')");
. "'{$seqname}_lock')");
if (DB::isError($result)) {
return $this->raiseError($result);
}
Expand Down Expand Up @@ -763,7 +763,7 @@ function nextId($seq_name, $ondemand = true)
function lastId($link_identifier = null)
{
$id = $this->connection->insert_id();
if(empty($id) || !is_int($id)) {
if (empty($id) || !is_int($id)) {
return 0;
}
return $id;
Expand All @@ -789,7 +789,7 @@ function createSequence($seq_name)
return $res;
}
// insert yields value 1, nextId call will generate ID 2
return $this->query("INSERT INTO ${seqname} (id) VALUES (0)");
return $this->query("INSERT INTO {$seqname} (id) VALUES (0)");
}

// }}}
Expand Down Expand Up @@ -828,7 +828,7 @@ function _BCsequence($seqname)
// Obtain a user-level lock... this will release any previous
// application locks, but unlike LOCK TABLES, it does not abort
// the current transaction and is much less frequently used.
$result = $this->getOne("SELECT GET_LOCK('${seqname}_lock',10)");
$result = $this->getOne("SELECT GET_LOCK('{$seqname}_lock',10)");
if (DB::isError($result)) {
return $result;
}
Expand All @@ -838,7 +838,7 @@ function _BCsequence($seqname)
return $this->mysqliRaiseError(DB_ERROR_NOT_LOCKED);
}

$highest_id = $this->getOne("SELECT MAX(id) FROM ${seqname}");
$highest_id = $this->getOne("SELECT MAX(id) FROM {$seqname}");
if (DB::isError($highest_id)) {
return $highest_id;
}
Expand All @@ -855,7 +855,7 @@ function _BCsequence($seqname)
// If another thread has been waiting for this lock,
// it will go thru the above procedure, but will have no
// real effect
$result = $this->getOne("SELECT RELEASE_LOCK('${seqname}_lock')");
$result = $this->getOne("SELECT RELEASE_LOCK('{$seqname}_lock')");
if (DB::isError($result)) {
return $result;
}
Expand Down
Loading

0 comments on commit 4efd340

Please sign in to comment.