mirror of
https://github.com/danog/sql.git
synced 2024-11-30 04:29:18 +01:00
Require 8.1 and make Transaction isolation an enum
This commit is contained in:
parent
55bfd0f439
commit
3698c20375
@ -11,16 +11,16 @@
|
||||
"homepage": "https://amphp.org",
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=8",
|
||||
"amphp/amp": "^3-dev"
|
||||
"php": ">=8.1",
|
||||
"amphp/amp": "^3"
|
||||
},
|
||||
"require-dev": {
|
||||
"amphp/php-cs-fixer-config": "dev-master",
|
||||
"amphp/phpunit-util": "^2-dev",
|
||||
"amphp/phpunit-util": "^3",
|
||||
"phpunit/phpunit": "^9",
|
||||
"psalm/phar": "^4.10"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"minimum-stability": "beta",
|
||||
"prefer-stable": true,
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
@ -4,7 +4,7 @@ namespace Amp\Sql;
|
||||
|
||||
abstract class ConnectionConfig
|
||||
{
|
||||
const KEY_MAP = [
|
||||
public const KEY_MAP = [
|
||||
'hostname' => 'host',
|
||||
'username' => 'user',
|
||||
'pass' => 'password',
|
||||
|
@ -7,9 +7,9 @@ interface Link extends Executor
|
||||
/**
|
||||
* Starts a transaction on a single connection.
|
||||
*
|
||||
* @param int $isolation Transaction isolation level.
|
||||
* @param TransactionIsolation $isolation Transaction isolation level.
|
||||
*
|
||||
* @return Transaction
|
||||
*/
|
||||
public function beginTransaction(int $isolation = Transaction::ISOLATION_COMMITTED): Transaction;
|
||||
public function beginTransaction(TransactionIsolation $isolation = TransactionIsolation::COMMITTED): Transaction;
|
||||
}
|
||||
|
@ -4,8 +4,7 @@ namespace Amp\Sql;
|
||||
|
||||
class QueryError extends \Error
|
||||
{
|
||||
/** @var string */
|
||||
protected string $query = "";
|
||||
protected readonly string $query;
|
||||
|
||||
public function __construct(string $message, string $query = "", \Throwable $previous = null)
|
||||
{
|
||||
|
@ -4,15 +4,7 @@ namespace Amp\Sql;
|
||||
|
||||
interface Transaction extends Executor
|
||||
{
|
||||
public const ISOLATION_UNCOMMITTED = 0;
|
||||
public const ISOLATION_COMMITTED = 1;
|
||||
public const ISOLATION_REPEATABLE = 2;
|
||||
public const ISOLATION_SERIALIZABLE = 4;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIsolationLevel(): int;
|
||||
public function getIsolationLevel(): TransactionIsolation;
|
||||
|
||||
/**
|
||||
* @return bool True if the transaction is active, false if it has been committed or rolled back.
|
||||
|
11
src/TransactionIsolation.php
Normal file
11
src/TransactionIsolation.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Amp\Sql;
|
||||
|
||||
enum TransactionIsolation
|
||||
{
|
||||
case UNCOMMITTED;
|
||||
case COMMITTED;
|
||||
case REPEATABLE;
|
||||
case SERIALIZABLE;
|
||||
}
|
Loading…
Reference in New Issue
Block a user