Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/*
3
 *  $Id: Exception.php 7490 2010-03-29 19:53:27Z 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.doctrine-project.org>.
20
 */
21
 
22
/**
23
 * Doctrine_Connection_Mysql_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: 7490 $
32
 * @link        www.doctrine-project.org
33
 */
34
class Doctrine_Connection_Mysql_Exception extends Doctrine_Connection_Exception
35
{
36
    /**
37
     * @var array $errorCodeMap         an array that is used for determining portable
38
     *                                  error code from a native database error code
39
     */
40
    protected static $errorCodeMap = array(
41
                                      1004 => Doctrine_Core::ERR_CANNOT_CREATE,
42
                                      1005 => Doctrine_Core::ERR_CANNOT_CREATE,
43
                                      1006 => Doctrine_Core::ERR_CANNOT_CREATE,
44
                                      1007 => Doctrine_Core::ERR_ALREADY_EXISTS,
45
                                      1008 => Doctrine_Core::ERR_CANNOT_DROP,
46
                                      1022 => Doctrine_Core::ERR_ALREADY_EXISTS,
47
                                      1044 => Doctrine_Core::ERR_ACCESS_VIOLATION,
48
                                      1046 => Doctrine_Core::ERR_NODBSELECTED,
49
                                      1048 => Doctrine_Core::ERR_CONSTRAINT,
50
                                      1049 => Doctrine_Core::ERR_NOSUCHDB,
51
                                      1050 => Doctrine_Core::ERR_ALREADY_EXISTS,
52
                                      1051 => Doctrine_Core::ERR_NOSUCHTABLE,
53
                                      1054 => Doctrine_Core::ERR_NOSUCHFIELD,
54
                                      1061 => Doctrine_Core::ERR_ALREADY_EXISTS,
55
                                      1062 => Doctrine_Core::ERR_ALREADY_EXISTS,
56
                                      1064 => Doctrine_Core::ERR_SYNTAX,
57
                                      1091 => Doctrine_Core::ERR_NOT_FOUND,
58
                                      1100 => Doctrine_Core::ERR_NOT_LOCKED,
59
                                      1136 => Doctrine_Core::ERR_VALUE_COUNT_ON_ROW,
60
                                      1142 => Doctrine_Core::ERR_ACCESS_VIOLATION,
61
                                      1146 => Doctrine_Core::ERR_NOSUCHTABLE,
62
                                      1216 => Doctrine_Core::ERR_CONSTRAINT,
63
                                      1217 => Doctrine_Core::ERR_CONSTRAINT,
64
                                      1451 => Doctrine_Core::ERR_CONSTRAINT,
65
                                      );
66
 
67
    /**
68
     * This method checks if native error code/message can be
69
     * converted into a portable code and then adds this
70
     * portable error code to $portableCode field
71
     *
72
     * @param array $errorInfo      error info array
73
     * @since 1.0
74
     * @return boolean              whether or not the error info processing was successfull
75
     *                              (the process is successfull if portable error code was found)
76
     */
77
    public function processErrorInfo(array $errorInfo)
78
    {
79
        $code = $errorInfo[1];
80
        if (isset(self::$errorCodeMap[$code])) {
81
            $this->portableCode = self::$errorCodeMap[$code];
82
            return true;
83
        }
84
        return false;
85
    }
86
}