~patrix-sbs/oraculum/git

« back to all changes in this revision

Viewing changes to models/doctrine/lib/Doctrine/Connection/Sqlite/Exception.php

  • Committer: Patrick Kaminski
  • Date: 2009-09-02 02:33:07 UTC
  • Revision ID: git-v1:943803254fca67bfb4c0374422b1b836b14dc518
Tags: v0.1a
Sending Oraculum Framework v0.1 alpha

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/*
 
3
 *  $Id: Exception.php 4252 2008-04-19 07:37:53Z jwage $
 
4
 *
 
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.
 
16
 *
 
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>.
 
20
 */
 
21
 
 
22
/**
 
23
 * Doctrine_Connection_Sqlite_Exception
 
24
 *
 
25
 * @package     Doctrine
 
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)
 
30
 * @since       1.0
 
31
 * @version     $Revision: 4252 $
 
32
 * @link        www.phpdoctrine.org
 
33
 */
 
34
class Doctrine_Connection_Sqlite_Exception extends Doctrine_Connection_Exception
 
35
{
 
36
    /**
 
37
     * @var array $errorRegexps         an array that is used for determining portable
 
38
     *                                  error code from a native database error message
 
39
     */
 
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,
 
53
                              );
 
54
 
 
55
    /**
 
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
 
59
     *
 
60
     * @param array $errorInfo      error info array
 
61
     * @since 1.0
 
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)
 
66
     */
 
67
    public function processErrorInfo(array $errorInfo)
 
68
    {
 
69
        foreach (self::$errorRegexps as $regexp => $code) {
 
70
            if (preg_match($regexp, $errorInfo[2])) {
 
71
 
 
72
                $this->portableCode = $code;
 
73
                return true;
 
74
            }
 
75
        }
 
76
        return false;
 
77
    }
 
78
}
 
 
b'\\ No newline at end of file'