Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Utils
  • none
  • Tracy
    • Bridges
      • Nette

Classes

  • Connection
  • Context
  • Helpers
  • ResultSet
  • Row
  • SqlLiteral
  • SqlPreprocessor
  • Structure

Interfaces

  • IConventions
  • IReflection
  • IRow
  • IRowContainer
  • IStructure
  • ISupplementalDriver

Exceptions

  • ConnectionException
  • ConstraintViolationException
  • DriverException
  • ForeignKeyConstraintViolationException
  • NotNullConstraintViolationException
  • UniqueConstraintViolationException
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (https://nette.org)
 5:  * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
 6:  */
 7: 
 8: namespace Nette\Database;
 9: 
10: 
11: /**
12:  * Base class for all errors in the driver or SQL server.
13:  */
14: class DriverException extends \PDOException
15: {
16:     /** @var string */
17:     public $queryString;
18: 
19: 
20:     /**
21:      * @return self
22:      */
23:     public static function from(\PDOException $src)
24:     {
25:         $e = new static($src->message, NULL, $src);
26:         if (!$src->errorInfo && preg_match('#SQLSTATE\[(.*?)\] \[(.*?)\] (.*)#A', $src->message, $m)) {
27:             $m[2] = (int) $m[2];
28:             $e->errorInfo = array_slice($m, 1);
29:             $e->code = $m[1];
30:         } else {
31:             $e->errorInfo = $src->errorInfo;
32:             $e->code = $src->code;
33:         }
34:         return $e;
35:     }
36: 
37: 
38:     /**
39:      * @return int|string|NULL  Driver-specific error code
40:      */
41:     public function getDriverCode()
42:     {
43:         return isset($this->errorInfo[1]) ? $this->errorInfo[1] : NULL;
44:     }
45: 
46: 
47:     /**
48:      * @return string|NULL  SQLSTATE error code
49:      */
50:     public function getSqlState()
51:     {
52:         return isset($this->errorInfo[0]) ? $this->errorInfo[0] : NULL;
53:     }
54: 
55: 
56:     /**
57:      * @return string|NULL  SQL command
58:      */
59:     public function getQueryString()
60:     {
61:         return $this->queryString;
62:     }
63: 
64: }
65: 
Nette 2.3-20161221 API API documentation generated by ApiGen 2.8.0