Skip to content

Commit ba37409

Browse files
author
Alin Olteanu
committed
FOR UPDATE SKIP LOCKED
1 parent e402fd8 commit ba37409

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@
3030
"AlinO\\Db\\": "src"
3131
}
3232
},
33-
"version": "3.1.0"
33+
"version": "3.1.1"
3434
}

src/MysqliDb.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@ class MysqliDb
203203
*/
204204
protected $_forUpdate = false;
205205

206+
/**
207+
* FOR UPDATE SKIP LOCKED flag
208+
*
209+
* @var bool
210+
*/
211+
protected $_forUpdateSkipLocked = false;
212+
206213
/**
207214
* LOCK IN SHARE MODE flag
208215
*
@@ -469,6 +476,7 @@ protected function reset()
469476
$this->returnType = 'array';
470477
$this->_nestJoin = false;
471478
$this->_forUpdate = false;
479+
$this->_forUpdateSkipLocked = false;
472480
$this->_lockInShareMode = false;
473481
$this->_tableName = '';
474482
$this->_lastInsertId = null;
@@ -720,6 +728,7 @@ public function setQueryOption($options)
720728
'QUICK',
721729
'MYSQLI_NESTJOIN',
722730
'FOR UPDATE',
731+
'FOR UPDATE SKIP LOCKED',
723732
'LOCK IN SHARE MODE'
724733
);
725734

@@ -737,6 +746,8 @@ public function setQueryOption($options)
737746
$this->_nestJoin = true;
738747
} elseif ($option == 'FOR UPDATE') {
739748
$this->_forUpdate = true;
749+
} elseif ($option == 'FOR UPDATE SKIP LOCKED') {
750+
$this->_forUpdateSkipLocked = true;
740751
} elseif ($option == 'LOCK IN SHARE MODE') {
741752
$this->_lockInShareMode = true;
742753
} else {
@@ -1692,6 +1703,9 @@ protected function _buildQuery($numRows = null, $tableData = null)
16921703
if ($this->_forUpdate) {
16931704
$this->_query .= ' FOR UPDATE';
16941705
}
1706+
if ($this->_forUpdateSkipLocked) {
1707+
$this->_query .= ' FOR UPDATE SKIP LOCKED';
1708+
}
16951709
if ($this->_lockInShareMode) {
16961710
$this->_query .= ' LOCK IN SHARE MODE';
16971711
}

0 commit comments

Comments
 (0)