]> git.openstreetmap.org Git - nominatim.git/blob - lib-php/DatabaseError.php
do not intermix params with and without default
[nominatim.git] / lib-php / DatabaseError.php
1 <?php
2
3 namespace Nominatim;
4
5 class DatabaseError extends \Exception
6 {
7
8     public function __construct($message, $code, $previous, $oPDOErr, $sSql = null)
9     {
10         parent::__construct($message, $code, $previous);
11         // https://secure.php.net/manual/en/class.pdoexception.php
12         $this->oPDOErr = $oPDOErr;
13         $this->sSql = $sSql;
14     }
15
16     public function __toString()
17     {
18         return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
19     }
20
21     public function getSqlError()
22     {
23         return $this->oPDOErr->getMessage();
24     }
25
26     public function getSqlDebugDump()
27     {
28         if (CONST_Debug) {
29             return var_export($this->oPDOErr, true);
30         } else {
31             return $this->sSql;
32         }
33     }
34 }