From 5f2fb569dddd92f630e808edb038a97e7e8a61dd Mon Sep 17 00:00:00 2001 From: Mark Newnham Date: Fri, 26 Mar 2021 20:17:34 -0600 Subject: Rewrite rowLock() method - update docblock - full rewrite of method based on firebird docs --- drivers/adodb-firebird.inc.php | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/drivers/adodb-firebird.inc.php b/drivers/adodb-firebird.inc.php index 7a00979d..2bcf9da1 100644 --- a/drivers/adodb-firebird.inc.php +++ b/drivers/adodb-firebird.inc.php @@ -299,7 +299,7 @@ class ADODB_firebird extends ADOConnection { * * @return array|bool An array of the indexes, or false if the query to get the indexes failed. */ - function metaIndexes($table, $primary = false, $owner = false) + public function metaIndexes($table, $primary = false, $owner = false) { // save old fetch mode global $ADODB_FETCH_MODE; @@ -357,14 +357,28 @@ class ADODB_firebird extends ADOConnection { } - // See http://community.borland.com/article/0,1410,25844,00.html - function RowLock($tables,$where,$col=false) + // See http://community.borland.com/article/0,1410,25844,00.html + /** + * Lock a table row for a duration of a transaction. + * + * @link https://adodb.org/dokuwiki/doku.php?id=v5:reference:connection:rowlock + * @link https://firebirdsql.org/refdocs/langrefupd21-notes-withlock.html + * + * @param string $tables The table(s) to lock rows for. + * @param string $where (Optional) The WHERE clause to use to determine which rows to lock. + * @param string $col (Optional) The columns to select. + * + * @return bool True if the locking SQL statement executed successfully, otherwise false. + */ + public function rowLock($tables,$where,$col=false) { - if ($this->autoCommit) { - $this->BeginTrans(); - } - $this->Execute("UPDATE $table SET $col=$col WHERE $where "); // is this correct - jlim? - return 1; + if ($this->transCnt==0) + $this->beginTrans(); + + if ($where) $where = ' where '.$where; + $rs = $this->execute("SELECT $col FROM $tables $where FOR UPDATE WITH LOCK"); + return + !empty($rs); } -- cgit v1.3