Skip to content

Commit 2f76624

Browse files
committed
PDO transactions
1 parent 619c100 commit 2f76624

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

src/Storage/PDOConnector.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,30 @@ public function setCredentials(array $credentials) {
4949
$this->credentials = $credentials;
5050
}
5151

52+
/**
53+
* starts a database transaction
54+
* @return bool
55+
*/
56+
public function startTransaction(): bool {
57+
return $this->pdo->beginTransaction();
58+
}
59+
60+
/**
61+
* commits a started database transaction
62+
* @return bool
63+
*/
64+
public function commit(): bool {
65+
return $this->pdo->commit();
66+
}
67+
68+
/**
69+
* rolls a started transaction back
70+
* @return bool
71+
*/
72+
public function rollback(): bool {
73+
return $this->pdo->rollBack();
74+
}
75+
5276
/**
5377
* connects to the database
5478
*
@@ -162,9 +186,9 @@ public function getLastInsertId($name = null) {
162186
*
163187
* @param string $param
164188
* @param $value
165-
* @param int $dataType
166-
* @param null $length
167-
* @param null $driverOptions
189+
* @param int $dataType
190+
* @param null $length
191+
* @param null $driverOptions
168192
*/
169193
public function bindParam(string $param, $value, $dataType = \PDO::PARAM_STR, $length = null, $driverOptions = null) {
170194
$this->statement->bindParam($param, $value, $dataType, $length, $driverOptions);

0 commit comments

Comments
 (0)