62 $query =
'SELECT owner, token, timeout, created, scope, depth, uri FROM ' . $this->tableName .
' WHERE (created > (? - timeout)) AND ((uri = ?)';
66 $uriParts = explode(
'/', $uri);
73 foreach ($uriParts as $part) {
75 if ($currentPath) $currentPath .=
'/';
76 $currentPath .= $part;
78 $query .=
' OR (depth!=0 AND uri = ?)';
83 if ($returnChildLocks) {
85 $query .=
' OR (uri LIKE ?)';
99 $lockInfo->owner = $row[
'owner'];
100 $lockInfo->token = $row[
'token'];
101 $lockInfo->timeout = $row[
'timeout'];
102 $lockInfo->created = $row[
'created'];
103 $lockInfo->scope = $row[
'scope'];
104 $lockInfo->depth = $row[
'depth'];
105 $lockInfo->uri = $row[
'uri'];
106 $lockList[] = $lockInfo;
124 $lockInfo->timeout = 30 * 60;
125 $lockInfo->created = time();
126 $lockInfo->uri = $uri;
128 $locks = $this->
getLocks($uri,
false);
130 foreach ($locks as $lock) {
131 if ($lock->token == $lockInfo->token) $exists =
true;
135 $stmt = $this->pdo->prepare(
'UPDATE ' . $this->tableName .
' SET owner = ?, timeout = ?, scope = ?, depth = ?, uri = ?, created = ? WHERE token = ?');
146 $stmt = $this->pdo->prepare(
'INSERT INTO ' . $this->tableName .
' (owner,timeout,scope,depth,uri,created,token) VALUES (?,?,?,?,?,?,?)');
173 $stmt = $this->pdo->prepare(
'DELETE FROM ' . $this->tableName .
' WHERE uri = ? AND token = ?');
174 $stmt->execute([$uri, $lockInfo->token]);
176 return $stmt->rowCount() === 1;
__construct(\PDO $pdo)
Constructor.
unlock($uri, LockInfo $lockInfo)
Removes a lock from a uri.
lock($uri, LockInfo $lockInfo)
Locks a uri.
This is an Abstract clas for lock backends.
getLocks($uri, $returnChildLocks)
Returns a list of Sabre objects.