3
* $Id: Exception.php 4252 2008-04-19 07:37:53Z jwage $
5
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17
* This software consists of voluntary contributions made by many individuals
18
* and is licensed under the LGPL. For more information, see
19
* <http://www.phpdoctrine.org>.
23
* Doctrine_Connection_Sqlite_Exception
26
* @subpackage Connection
27
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
28
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
29
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
31
* @version $Revision: 4252 $
32
* @link www.phpdoctrine.org
34
class Doctrine_Connection_Sqlite_Exception extends Doctrine_Connection_Exception
37
* @var array $errorRegexps an array that is used for determining portable
38
* error code from a native database error message
40
protected static $errorRegexps = array(
41
'/^no such table:/' => Doctrine::ERR_NOSUCHTABLE,
42
'/^no such index:/' => Doctrine::ERR_NOT_FOUND,
43
'/^(table|index) .* already exists$/' => Doctrine::ERR_ALREADY_EXISTS,
44
'/PRIMARY KEY must be unique/i' => Doctrine::ERR_CONSTRAINT,
45
'/is not unique/' => Doctrine::ERR_CONSTRAINT,
46
'/columns .* are not unique/i' => Doctrine::ERR_CONSTRAINT,
47
'/uniqueness constraint failed/' => Doctrine::ERR_CONSTRAINT,
48
'/may not be NULL/' => Doctrine::ERR_CONSTRAINT_NOT_NULL,
49
'/^no such column:/' => Doctrine::ERR_NOSUCHFIELD,
50
'/column not present in both tables/i' => Doctrine::ERR_NOSUCHFIELD,
51
'/^near ".*": syntax error$/' => Doctrine::ERR_SYNTAX,
52
'/[0-9]+ values for [0-9]+ columns/i' => Doctrine::ERR_VALUE_COUNT_ON_ROW,
56
* This method checks if native error code/message can be
57
* converted into a portable code and then adds this
58
* portable error code to $portableCode field
60
* @param array $errorInfo error info array
62
* @see Doctrine::ERR_* constants
63
* @see Doctrine_Connection::$portableCode
64
* @return boolean whether or not the error info processing was successfull
65
* (the process is successfull if portable error code was found)
67
public function processErrorInfo(array $errorInfo)
69
foreach (self::$errorRegexps as $regexp => $code) {
70
if (preg_match($regexp, $errorInfo[2])) {
72
$this->portableCode = $code;
b'\\ No newline at end of file'