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
f11fe0ca
Commit
f11fe0ca
authored
Aug 31, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Possibility to pass the hasColumn constraint/validator arg as an array
parent
c9291743
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
27 deletions
+42
-27
DataDict.php
Doctrine/DataDict.php
+4
-1
Identifier.php
Doctrine/Identifier.php
+0
-4
Pessimistic.php
Doctrine/Locking/Manager/Pessimistic.php
+4
-4
Record.php
Doctrine/Record.php
+1
-1
Table.php
Doctrine/Table.php
+33
-17
No files found.
Doctrine/DataDict.php
View file @
f11fe0ca
...
...
@@ -32,7 +32,10 @@ class Doctrine_DataDict {
*/
public
function
createTable
(
$tablename
,
array
$columns
)
{
foreach
(
$columns
as
$name
=>
$args
)
{
$r
[]
=
$name
.
" "
.
$this
->
getADOType
(
$args
[
0
],
$args
[
1
])
.
" "
.
str_replace
(
"|"
,
" "
,
$args
[
2
]);
if
(
!
is_array
(
$args
[
2
]))
$args
[
2
]
=
array
();
$r
[]
=
$name
.
" "
.
$this
->
getADOType
(
$args
[
0
],
$args
[
1
])
.
" "
.
implode
(
' '
,
$args
[
2
]);
}
...
...
Doctrine/Identifier.php
View file @
f11fe0ca
<?php
class
Doctrine_Identifier
{
/**
* constant for unique identifier
*/
const
UNIQUE
=
0
;
/**
* constant for auto_increment identifier
*/
...
...
Doctrine/Locking/Manager/Pessimistic.php
View file @
f11fe0ca
...
...
@@ -37,10 +37,10 @@ class Doctrine_Locking_Manager_Pessimistic
if
(
$this
->
_dataSource
->
getAttribute
(
Doctrine
::
ATTR_CREATE_TABLES
)
===
true
)
{
$columns
=
array
();
$columns
[
'object_type'
]
=
array
(
'string'
,
50
,
'notnull|primary'
);
$columns
[
'object_key'
]
=
array
(
'string'
,
250
,
'notnull|primary'
);
$columns
[
'user_ident'
]
=
array
(
'string'
,
50
,
'notnull'
);
$columns
[
'timestamp_obtained'
]
=
array
(
'integer'
,
10
,
'notnull'
);
$columns
[
'object_type'
]
=
array
(
'string'
,
50
,
array
(
'notnull'
,
'primary'
)
);
$columns
[
'object_key'
]
=
array
(
'string'
,
250
,
array
(
'notnull'
,
'primary'
)
);
$columns
[
'user_ident'
]
=
array
(
'string'
,
50
,
array
(
'notnull'
)
);
$columns
[
'timestamp_obtained'
]
=
array
(
'integer'
,
10
,
array
(
'notnull'
)
);
$dataDict
=
new
Doctrine_DataDict
(
$this
->
_dataSource
->
getDBH
());
$dataDict
->
createTable
(
$this
->
_lockTable
,
$columns
);
...
...
Doctrine/Record.php
View file @
f11fe0ca
...
...
@@ -274,7 +274,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$value
=
unserialize
(
$tmp
[
$name
]);
if
(
$value
===
false
)
throw
new
Doctrine_Exception
(
"Unserialization of
$name
failed. "
.
var_dump
(
$tmp
[
$name
],
true
));
throw
new
Doctrine_
Record_
Exception
(
"Unserialization of
$name
failed. "
.
var_dump
(
$tmp
[
$name
],
true
));
}
else
$value
=
$tmp
[
$name
];
...
...
Doctrine/Table.php
View file @
f11fe0ca
<?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>.
*/
require_once
(
"Exception/Find.class.php"
);
require_once
(
"Exception/Mapping.class.php"
);
require_once
(
"Exception/PrimaryKey.class.php"
);
...
...
@@ -158,7 +177,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
switch
(
count
(
$this
->
primaryKeys
))
:
case
0
:
$this
->
columns
=
array_merge
(
array
(
"id"
=>
array
(
"integer"
,
11
,
"autoincrement|primary"
)),
$this
->
columns
);
$this
->
columns
=
array_merge
(
array
(
"id"
=>
array
(
"integer"
,
11
,
array
(
"autoincrement"
,
"primary"
)
)),
$this
->
columns
);
$this
->
primaryKeys
[]
=
"id"
;
$this
->
identifier
=
"id"
;
$this
->
identifierType
=
Doctrine_Identifier
::
AUTO_INCREMENT
;
...
...
@@ -171,10 +190,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
}
else
{
foreach
(
$this
->
primaryKeys
as
$pk
)
{
$o
=
$this
->
columns
[
$pk
][
2
];
$e
=
explode
(
"|"
,
$o
);
$found
=
false
;
$e
=
$this
->
columns
[
$pk
][
2
];
$found
=
false
;
foreach
(
$e
as
$option
)
{
if
(
$found
)
...
...
@@ -183,10 +201,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$e2
=
explode
(
":"
,
$option
);
switch
(
strtolower
(
$e2
[
0
]))
:
case
"unique"
:
$this
->
identifierType
=
Doctrine_Identifier
::
UNIQUE
;
$found
=
true
;
break
;
case
"autoincrement"
:
$this
->
identifierType
=
Doctrine_Identifier
::
AUTO_INCREMENT
;
$found
=
true
;
...
...
@@ -261,11 +275,13 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
* @param mixed $options
* @return void
*/
final
public
function
setColumn
(
$name
,
$type
,
$length
,
$options
=
""
)
{
final
public
function
setColumn
(
$name
,
$type
,
$length
,
$options
=
array
())
{
if
(
is_string
(
$options
))
$options
=
explode
(
'|'
,
$options
);
$this
->
columns
[
$name
]
=
array
(
$type
,
$length
,
$options
);
$e
=
explode
(
"|"
,
$options
);
if
(
in_array
(
"primary"
,
$e
))
{
if
(
in_array
(
"primary"
,
$options
))
{
$this
->
primaryKeys
[]
=
$name
;
}
}
...
...
@@ -525,7 +541,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
* @param string $name component name of which a foreign key object is bound
* @return boolean
*/
final
public
function
has
ForeignKey
(
$name
)
{
final
public
function
has
Relation
(
$name
)
{
if
(
isset
(
$this
->
bound
[
$name
]))
return
true
;
...
...
@@ -565,7 +581,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$relation
=
new
Doctrine_LocalKey
(
$table
,
$foreign
,
$local
,
$type
,
$alias
);
}
else
throw
new
Doctrine_
Mapping
_Exception
(
"Only one-to-one relations are possible when local reference key is used."
);
throw
new
Doctrine_
Table
_Exception
(
"Only one-to-one relations are possible when local reference key is used."
);
}
elseif
(
$component
==
$name
||
(
$component
==
$alias
&&
$name
==
$this
->
name
))
{
if
(
!
isset
(
$local
))
...
...
@@ -579,7 +595,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
// only aggregate relations allowed
if
(
$type
!=
Doctrine_Relation
::
MANY_AGGREGATE
)
throw
new
Doctrine_
Mapping
_Exception
(
"Only aggregate relations are allowed for many-to-many relations"
);
throw
new
Doctrine_
Table
_Exception
(
"Only aggregate relations are allowed for many-to-many relations"
);
$classes
=
array_merge
(
$this
->
parents
,
array
(
$this
->
name
));
...
...
@@ -597,7 +613,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$fields
=
explode
(
"-"
,
$e2
[
1
]);
if
(
$e2
[
0
]
!=
$component
)
throw
new
Doctrine_
Mapping
_Exception
(
$e2
[
0
]
.
" doesn't match "
.
$component
);
throw
new
Doctrine_
Table
_Exception
(
$e2
[
0
]
.
" doesn't match "
.
$component
);
$associationTable
=
$this
->
connection
->
getTable
(
$e2
[
0
]);
...
...
@@ -617,7 +633,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$this
->
relations
[
$alias
]
=
$relation
;
return
$this
->
relations
[
$alias
];
}
throw
new
InvalidKey
Exception
(
'Unknown relation '
.
$original
);
throw
new
Doctrine_Table_
Exception
(
'Unknown relation '
.
$original
);
}
/**
* returns an array containing all foreign key objects
...
...
@@ -795,7 +811,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$this
->
data
=
$this
->
connection
->
execute
(
$query
,
$params
)
->
fetch
(
PDO
::
FETCH_ASSOC
);
if
(
$this
->
data
===
false
)
throw
new
Doctrine_Find_Exception
()
;
return
false
;
}
return
$this
->
getRecord
();
}
...
...
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