Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace Doctrine\DBAL\Driver\Mysqli\Exception;
6
 
7
use Doctrine\DBAL\Driver\AbstractException;
8
use mysqli_sql_exception;
9
use mysqli_stmt;
10
use ReflectionProperty;
11
 
12
/**
13
 * @internal
14
 *
15
 * @psalm-immutable
16
 */
17
final class StatementError extends AbstractException
18
{
19
    public static function new(mysqli_stmt $statement): self
20
    {
21
        return new self($statement->error, $statement->sqlstate, $statement->errno);
22
    }
23
 
24
    public static function upcast(mysqli_sql_exception $exception): self
25
    {
26
        $p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate');
27
        $p->setAccessible(true);
28
 
29
        return new self($exception->getMessage(), $p->getValue($exception), (int) $exception->getCode(), $exception);
30
    }
31
}