3 namespace RedBeanPHP\RedException;
5 use RedBeanPHP\RedException as RedException;
9 * Represents a generic database exception independent of the underlying driver.
11 * @file RedBeanPHP/RedException/SQL.php
12 * @author Gabor de Mooij and the RedBeanPHP Community
16 * (c) copyright G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
17 * This source file is subject to the BSD/GPLv2 License that is bundled
18 * with this source code in the file license.txt.
20 class SQL extends RedException
28 * Returns an ANSI-92 compliant SQL state.
32 public function getSQLState()
34 return $this->sqlState;
38 * Returns the raw SQL STATE, possibly compliant with
39 * ANSI SQL error codes - but this depends on database driver.
41 * @param string $sqlState SQL state error code
45 public function setSQLState( $sqlState )
47 $this->sqlState = $sqlState;
51 * To String prints both code and SQL state.
55 public function __toString()
57 return '[' . $this->getSQLState() . '] - ' . $this->getMessage()."\n".
58 'trace: ' . $this->getTraceAsString();