X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=lib%2Fpq%2FGateway%2FRowset.php;h=15352591e282a95f5aac57177b1908d1855da5be;hb=c05be811151dbbd5a9b35e886db081bee8338581;hp=c0a337088ee6da3391c3ca53d6326367ec1692c4;hpb=eb9591d498ac4a2a448d6021c804b3c41d1c7247;p=m6w6%2Fpq-gateway diff --git a/lib/pq/Gateway/Rowset.php b/lib/pq/Gateway/Rowset.php index c0a3370..1535259 100644 --- a/lib/pq/Gateway/Rowset.php +++ b/lib/pq/Gateway/Rowset.php @@ -99,12 +99,14 @@ class Rowset implements \SeekableIterator, \Countable, \JsonSerializable /** * Create all rows of this rowset - * @param bool $txn + * @param mixed $txn * @return \pq\Gateway\Rowset * @throws Exception */ function create($txn = true) { - $txn = $txn ? $this->table->getConnection()->startTransaction() : false; + if ($txn && !($txn instanceof pq\Transaction)) { + $txn = $this->table->getConnection()->startTransaction(); + } try { foreach ($this->rows as $row) { $row->create(); @@ -123,12 +125,14 @@ class Rowset implements \SeekableIterator, \Countable, \JsonSerializable /** * Update all rows of this rowset - * @param bool $txn + * @param mixed $txn * @return \pq\Gateway\Rowset * @throws \Exception */ function update($txn = true) { - $txn = $txn ? $this->table->getConnection()->startTransaction() : false; + if ($txn && !($txn instanceof pq\Transaction)) { + $txn = $this->table->getConnection()->startTransaction(); + } try { foreach ($this->rows as $row) { $row->update(); @@ -147,12 +151,14 @@ class Rowset implements \SeekableIterator, \Countable, \JsonSerializable /** * Delete all rows of this rowset - * @param type $txn + * @param mixed $txn * @return \pq\Gateway\Rowset * @throws \Exception */ function delete($txn = true) { - $txn = $txn ? $this->table->getConnection()->startTransaction() : false; + if ($txn && !($txn instanceof pq\Transaction)) { + $txn = $this->table->getConnection()->startTransaction(); + } try { foreach ($this->rows as $row) { $row->delete();