Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
eef1bd48
Commit
eef1bd48
authored
Nov 10, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Portable error code updates
parent
90e28874
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
117 deletions
+84
-117
Doctrine.php
lib/Doctrine.php
+37
-49
Mssql.php
lib/Doctrine/Connection/Mssql/Mssql.php
+46
-4
Exception.php
lib/Doctrine/Connection/Sqlite/Exception.php
+1
-1
Sqlite.php
lib/Doctrine/Db/Sqlite.php
+0
-63
No files found.
lib/Doctrine.php
View file @
eef1bd48
...
@@ -31,55 +31,43 @@ require_once("Doctrine/Exception.php");
...
@@ -31,55 +31,43 @@ require_once("Doctrine/Exception.php");
*/
*/
final
class
Doctrine
{
final
class
Doctrine
{
/**
/**
* ERROR MODE CONSTANTS
* error constants
*/
*/
const
ERR
=
-
1
;
/**
const
ERR_SYNTAX
=
-
2
;
* NO PRIMARY KEY COLUMN ERROR
const
ERR_CONSTRAINT
=
-
3
;
* no primary key column found error code
const
ERR_NOT_FOUND
=
-
4
;
*/
const
ERR_ALREADY_EXISTS
=
-
5
;
const
ERR_NO_PK
=
0
;
const
ERR_UNSUPPORTED
=
-
6
;
/**
const
ERR_MISMATCH
=
-
7
;
* PRIMARY KEY MISMATCH ERROR
const
ERR_INVALID
=
-
8
;
* this error code is used when user uses factory refresh for a
const
ERR_NOT_CAPABLE
=
-
9
;
* given Doctrine_Record and the old primary key doesn't match the new one
const
ERR_TRUNCATED
=
-
10
;
*/
const
ERR_INVALID_NUMBER
=
-
11
;
const
ERR_REFRESH
=
1
;
const
ERR_INVALID_DATE
=
-
12
;
/**
const
ERR_DIVZERO
=
-
13
;
* FIND ERROR
const
ERR_NODBSELECTED
=
-
14
;
* this code used when for example Doctrine_Table::find() is called and
const
ERR_CANNOT_CREATE
=
-
15
;
* a Data Access Object is not found
const
ERR_CANNOT_DELETE
=
-
16
;
*/
const
ERR_CANNOT_DROP
=
-
17
;
const
ERR_FIND
=
2
;
const
ERR_NOSUCHTABLE
=
-
18
;
/**
const
ERR_NOSUCHFIELD
=
-
19
;
* TABLE NOT FOUND ERROR
const
ERR_NEED_MORE_DATA
=
-
20
;
* this error code is used when user tries to initialize
const
ERR_NOT_LOCKED
=
-
21
;
* a table and there is no database table for this factory
const
ERR_VALUE_COUNT_ON_ROW
=
-
22
;
*/
const
ERR_INVALID_DSN
=
-
23
;
const
ERR_NOSUCH_TABLE
=
3
;
const
ERR_CONNECT_FAILED
=
-
24
;
/**
const
ERR_EXTENSION_NOT_FOUND
=
-
25
;
* NAMING ERROR
const
ERR_NOSUCHDB
=
-
26
;
* this code is used when user defined Doctrine_Table is badly named
const
ERR_ACCESS_VIOLATION
=
-
27
;
*/
const
ERR_CANNOT_REPLACE
=
-
28
;
const
ERR_NAMING
=
5
;
const
ERR_CONSTRAINT_NOT_NULL
=
-
29
;
/**
const
ERR_DEADLOCK
=
-
30
;
* TABLE INSTANCE ERROR
const
ERR_CANNOT_ALTER
=
-
31
;
* this code is used when user tries to initialize
const
ERR_MANAGER
=
-
32
;
* a table that is already initialized
const
ERR_MANAGER_PARSE
=
-
33
;
*/
const
ERR_LOADMODULE
=
-
34
;
const
ERR_TABLE_INSTANCE
=
6
;
const
ERR_INSUFFICIENT_DATA
=
-
35
;
/**
* NO OPEN SESSIONS ERROR
* error code which is used when user tries to get
* current session are there are no sessions open
*/
const
ERR_NO_SESSIONS
=
7
;
/**
* MAPPING ERROR
* if there is something wrong with mapping logic
* this error code is used
*/
const
ERR_MAPPING
=
8
;
/**
/**
* ATTRIBUTE CONSTANTS
* ATTRIBUTE CONSTANTS
...
...
lib/Doctrine/Connection/Mssql/Mssql.php
View file @
eef1bd48
...
@@ -22,8 +22,50 @@ Doctrine::autoload('Doctrine_Connection_Exception');
...
@@ -22,8 +22,50 @@ Doctrine::autoload('Doctrine_Connection_Exception');
/**
/**
* Doctrine_Connection_Mssql_Exception
* Doctrine_Connection_Mssql_Exception
*
*
* @package Doctrine ORM
* @package Doctrine
* @url www.phpdoctrine.com
* @url http://www.phpdoctrine.com
* @license LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @author Konsta Vesterinen
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @since 1.0
* @version $Id$
*/
*/
class
Doctrine_Connection_Mssql_Exception
extends
Doctrine_Connection_Exception
{
}
class
Doctrine_Connection_Mssql_Exception
extends
Doctrine_Connection_Exception
{
/**
* @var array $errorRegexps an array that is used for determining portable
* error code from a native database error code
*/
protected
static
$errorCodeMap
=
array
(
110
=>
MDB2_ERROR_VALUE_COUNT_ON_ROW
,
155
=>
MDB2_ERROR_NOSUCHFIELD
,
170
=>
MDB2_ERROR_SYNTAX
,
207
=>
MDB2_ERROR_NOSUCHFIELD
,
208
=>
MDB2_ERROR_NOSUCHTABLE
,
245
=>
MDB2_ERROR_INVALID_NUMBER
,
515
=>
MDB2_ERROR_CONSTRAINT_NOT_NULL
,
547
=>
MDB2_ERROR_CONSTRAINT
,
1913
=>
MDB2_ERROR_ALREADY_EXISTS
,
2627
=>
MDB2_ERROR_CONSTRAINT
,
2714
=>
MDB2_ERROR_ALREADY_EXISTS
,
3701
=>
MDB2_ERROR_NOSUCHTABLE
,
8134
=>
MDB2_ERROR_DIVZERO
,
);
/**
* This method checks if native error code/message can be
* converted into a portable code and then adds this
* portable error code to errorInfo array and returns the modified array
*
* the portable error code is added at the end of array
*
* @param array $errorInfo error info array
* @since 1.0
* @return array
*/
public
function
processErrorInfo
(
array
$errorInfo
)
{
$code
=
$errorInfo
[
1
];
if
(
isset
(
self
::
$errorCodeMap
[
$code
]))
$errorInfo
[
3
]
=
self
::
$errorCodeMap
[
$code
];
return
$errorInfo
;
}
}
lib/Doctrine/Connection/Sqlite/Exception.php
View file @
eef1bd48
...
@@ -57,7 +57,7 @@ class Doctrine_Connection_Sqlite_Exception extends Doctrine_Connection_Exception
...
@@ -57,7 +57,7 @@ class Doctrine_Connection_Sqlite_Exception extends Doctrine_Connection_Exception
*
*
* the portable error code is added at the end of array
* the portable error code is added at the end of array
*
*
* @param array $errorInfo
* @param array $errorInfo
error info array
* @since 1.0
* @since 1.0
* @return array
* @return array
*/
*/
...
...
lib/Doctrine/Db/Sqlite.php
deleted
100644 → 0
View file @
90e28874
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
Doctrine
::
autoload
(
'Doctrine_Db'
);
/**
* @package Doctrine
* @url http://www.phpdoctrine.com
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @author Konsta Vesterinen
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @version $Id$
*/
class
Doctrine_Db_Sqlite
extends
Doctrine_Db
{
protected
static
$errorRegexps
=
array
(
'/^no such table:/'
=>
Doctrine_Db
::
ERR_NOSUCHTABLE
,
'/^no such index:/'
=>
Doctrine_Db
::
ERR_NOT_FOUND
,
'/^(table|index) .* already exists$/'
=>
Doctrine_Db
::
ERR_ALREADY_EXISTS
,
'/PRIMARY KEY must be unique/i'
=>
Doctrine_Db
::
ERR_CONSTRAINT
,
'/is not unique/'
=>
Doctrine_Db
::
ERR_CONSTRAINT
,
'/columns .* are not unique/i'
=>
Doctrine_Db
::
ERR_CONSTRAINT
,
'/uniqueness constraint failed/'
=>
Doctrine_Db
::
ERR_CONSTRAINT
,
'/may not be NULL/'
=>
Doctrine_Db
::
ERR_CONSTRAINT_NOT_NULL
,
'/^no such column:/'
=>
Doctrine_Db
::
ERR_NOSUCHFIELD
,
'/column not present in both tables/i'
=>
Doctrine_Db
::
ERR_NOSUCHFIELD
,
'/^near ".*": syntax error$/'
=>
Doctrine_Db
::
ERR_SYNTAX
,
'/[0-9]+ values for [0-9]+ columns/i'
=>
Doctrine_Db
::
ERR_VALUE_COUNT_ON_ROW
,
);
/**
* This method is used to collect information about an error
*
* @param integer $error
* @return array
* @access public
*/
public
function
processErrorInfo
(
array
$errorInfo
)
{
foreach
(
self
::
$errorRegexps
as
$regexp
=>
$code
)
{
if
(
preg_match
(
$regexp
,
$native_msg
))
{
$error
=
$code
;
break
;
}
}
return
array
(
$error
,
$native_code
,
$native_msg
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment