Files
MeshVault/tests/Integration/CatalogLockStatement.php
T

25 lines
600 B
PHP

<?php
declare(strict_types=1);
namespace MeshVault\Tests\Integration;
use ArrayObject;
use PDOStatement;
/** Records execution, including the lock attempt that throws, rather than just SQL preparation. */
final class CatalogLockStatement extends PDOStatement
{
protected function __construct(private ArrayObject $locks)
{
}
public function execute(?array $params = null): bool
{
if (preg_match('/SELECT .* FROM files WHERE id = \? FOR UPDATE$/i', $this->queryString)) {
$this->locks[] = $params;
}
return parent::execute($params);
}
}