|
|
|
|
@ -25,6 +25,7 @@ |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
namespace OC\DB; |
|
|
|
|
|
|
|
|
|
use Doctrine\DBAL\DBALException; |
|
|
|
|
use Doctrine\DBAL\Driver; |
|
|
|
|
use Doctrine\DBAL\Configuration; |
|
|
|
|
@ -46,6 +47,8 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection { |
|
|
|
|
*/ |
|
|
|
|
protected $adapter; |
|
|
|
|
|
|
|
|
|
protected $lockedTable = null; |
|
|
|
|
|
|
|
|
|
public function connect() { |
|
|
|
|
try { |
|
|
|
|
return parent::connect(); |
|
|
|
|
@ -281,7 +284,7 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection { |
|
|
|
|
foreach ($values as $name => $value) { |
|
|
|
|
$updateQb->set($name, $updateQb->createNamedParameter($value, $this->getType($value))); |
|
|
|
|
} |
|
|
|
|
$where = $updateQb->expr()->andx(); |
|
|
|
|
$where = $updateQb->expr()->andX(); |
|
|
|
|
$whereValues = array_merge($keys, $updatePreconditionValues); |
|
|
|
|
foreach ($whereValues as $name => $value) { |
|
|
|
|
$where->add($updateQb->expr()->eq( |
|
|
|
|
@ -301,6 +304,33 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create an exclusive read+write lock on a table |
|
|
|
|
* |
|
|
|
|
* @param string $tableName |
|
|
|
|
* @throws \BadMethodCallException When trying to acquire a second lock |
|
|
|
|
* @since 9.1.0 |
|
|
|
|
*/ |
|
|
|
|
public function lockTable($tableName) { |
|
|
|
|
if ($this->lockedTable !== null) { |
|
|
|
|
throw new \BadMethodCallException('Can not lock a new table until the previous lock is released.'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$tableName = $this->tablePrefix . $tableName; |
|
|
|
|
$this->lockedTable = $tableName; |
|
|
|
|
$this->adapter->lockTable($tableName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Release a previous acquired lock again |
|
|
|
|
* |
|
|
|
|
* @since 9.1.0 |
|
|
|
|
*/ |
|
|
|
|
public function unlockTable() { |
|
|
|
|
$this->adapter->unlockTable(); |
|
|
|
|
$this->lockedTable = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* returns the error code and message as a string for logging |
|
|
|
|
* works with DoctrineException |
|
|
|
|
|