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
ade4cd2a
Commit
ade4cd2a
authored
Feb 11, 2008
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cosmetics
parent
57abb796
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
228 additions
and
93 deletions
+228
-93
ClassMetadata.php
lib/Doctrine/ClassMetadata.php
+165
-67
Factory.php
lib/Doctrine/ClassMetadata/Factory.php
+37
-13
NestedSet.php
lib/Doctrine/Node/NestedSet.php
+1
-1
TestTest.php
tests/Orm/Component/TestTest.php
+2
-2
users.php
tests/fixtures/forum/common/users.php
+1
-1
ForumUser.php
tests/models/forum/ForumUser.php
+0
-9
Forum_User.php
tests/models/forum/Forum_User.php
+22
-0
No files found.
lib/Doctrine/ClassMetadata.php
View file @
ade4cd2a
This diff is collapsed.
Click to expand it.
lib/Doctrine/ClassMetadata/Factory.php
View file @
ade4cd2a
<?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.org>.
*/
/**
* A table factory is used to create table objects and load them with meta data.
* The metadata factory is used to create ClassMetadata objects that contain all the
* metadata of a class.
*
* @todo Support different drivers for loading the metadata from different sources.
* @package Doctrine
* @since 1.0
*/
class
Doctrine_ClassMetadata_Factory
{
...
...
@@ -12,10 +32,18 @@ class Doctrine_ClassMetadata_Factory
protected
$_driver
;
/**
*
*
The already loaded metadata objects.
*/
protected
$_loadedMetadata
=
array
();
/**
* Constructor.
* Creates a new factory instance that uses the given connection and metadata driver
* implementations.
*
* @param $conn The connection to use.
* @param $driver The metadata driver to use.
*/
public
function
__construct
(
Doctrine_Connection
$conn
,
$driver
)
{
$this
->
_conn
=
$conn
;
...
...
@@ -87,7 +115,6 @@ class Doctrine_ClassMetadata_Factory
$this
->
_addInheritedRelations
(
$subClass
,
$parent
);
$this
->
_loadMetadata
(
$subClass
,
$subclassName
);
if
(
$parent
->
getInheritanceType
()
==
Doctrine
::
INHERITANCETYPE_SINGLE_TABLE
)
{
//echo "<br />". $subClass->getClassName() . $parent->getTableName() . "<br />";
$subClass
->
setTableName
(
$parent
->
getTableName
());
}
$classes
[
$subclassName
]
=
$subClass
;
...
...
@@ -98,12 +125,9 @@ class Doctrine_ClassMetadata_Factory
protected
function
_addInheritedFields
(
$subClass
,
$parentClass
)
{
foreach
(
$parentClass
->
getColumns
()
as
$name
=>
$definition
)
{
/*if (isset($definition['autoincrement']) && $definition['autoincrement'] === true) {
unset($definition['autoincrement']);
}*/
$fullName
=
"
$name
as "
.
$parentClass
->
getFieldName
(
$name
);
$definition
[
'inherited'
]
=
true
;
$subClass
->
set
Column
(
$fullName
,
$definition
[
'type'
],
$definition
[
'length'
],
$subClass
->
addMapped
Column
(
$fullName
,
$definition
[
'type'
],
$definition
[
'length'
],
$definition
);
}
}
...
...
@@ -145,7 +169,7 @@ class Doctrine_ClassMetadata_Factory
}
// save parents
$class
->
set
Option
(
'parents'
,
$names
);
$class
->
set
ParentClasses
(
$names
);
// load further metadata
$this
->
_driver
->
loadMetadataForClass
(
$name
,
$class
);
...
...
@@ -244,13 +268,13 @@ class Doctrine_ClassMetadata_Factory
$found
=
true
;
if
(
$value
)
{
$class
->
setOption
(
'sequenceName'
,
$value
);
$class
->
set
Table
Option
(
'sequenceName'
,
$value
);
}
else
{
if
((
$sequence
=
$class
->
getAttribute
(
Doctrine
::
ATTR_DEFAULT_SEQUENCE
))
!==
null
)
{
$class
->
setOption
(
'sequenceName'
,
$sequence
);
$class
->
set
Table
Option
(
'sequenceName'
,
$sequence
);
}
else
{
$class
->
setOption
(
'sequenceName'
,
$class
->
getConnection
()
->
getSequenceName
(
$class
->
get
Option
(
'tableName'
)));
$class
->
set
Table
Option
(
'sequenceName'
,
$class
->
getConnection
()
->
getSequenceName
(
$class
->
get
TableName
(
)));
}
}
break
;
...
...
lib/Doctrine/Node/NestedSet.php
View file @
ade4cd2a
...
...
@@ -60,7 +60,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
*/
public
function
hasChildren
()
{
return
((
$this
->
getRightValue
()
-
$this
->
getLeftValue
()
)
>
1
);
return
((
$this
->
getRightValue
()
-
$this
->
getLeftValue
()
)
>
1
);
}
/**
...
...
tests/Orm/Component/TestTest.php
View file @
ade4cd2a
...
...
@@ -16,7 +16,7 @@ class Orm_Component_TestTest extends Doctrine_OrmTestCase
public
function
testFixture
()
{
$forumUsers
=
$this
->
sharedFixture
[
'connection'
]
->
query
(
"FROM ForumUser u"
);
$forumUsers
=
$this
->
sharedFixture
[
'connection'
]
->
query
(
"FROM Forum
_
User u"
);
$this
->
assertEquals
(
2
,
count
(
$forumUsers
));
$forumUsers
[
0
]
->
delete
();
unset
(
$forumUsers
[
0
]);
...
...
@@ -25,7 +25,7 @@ class Orm_Component_TestTest extends Doctrine_OrmTestCase
public
function
testFixture2
()
{
$forumUsers
=
$this
->
sharedFixture
[
'connection'
]
->
query
(
"FROM ForumUser u"
);
$forumUsers
=
$this
->
sharedFixture
[
'connection'
]
->
query
(
"FROM Forum
_
User u"
);
$this
->
assertEquals
(
2
,
count
(
$forumUsers
));
}
}
\ No newline at end of file
tests/fixtures/forum/common/users.php
View file @
ade4cd2a
<?php
$fixture
=
array
(
'model'
=>
'ForumUser'
,
'model'
=>
'Forum
_
User'
,
'rows'
=>
array
(
array
(
'id'
=>
1
,
...
...
tests/models/forum/ForumUser.php
deleted
100644 → 0
View file @
57abb796
<?php
class
ForumUser
extends
Doctrine_Record
{
public
static
function
initMetadata
(
$class
)
{
$class
->
setColumn
(
'id'
,
'integer'
,
4
,
array
(
'primary'
=>
true
,
'autoincrement'
=>
true
));
$class
->
setColumn
(
'username'
,
'string'
,
255
);
}
}
\ No newline at end of file
tests/models/forum/Forum_User.php
0 → 100644
View file @
ade4cd2a
<?php
class
Forum_User
extends
Doctrine_Record
{
public
static
function
initMetadata
(
$class
)
{
// inheritance mapping
$class
->
setInheritanceType
(
Doctrine
::
INHERITANCETYPE_JOINED
,
array
(
'discriminatorColumn'
=>
'dtype'
,
'discriminatorMap'
=>
array
(
1
=>
'Forum_User'
,
2
=>
'Forum_Administrator'
)
));
$class
->
setSubclasses
(
array
(
'Forum_Administrator'
));
// property mapping
$class
->
addMappedColumn
(
'id'
,
'integer'
,
4
,
array
(
'primary'
=>
true
,
'autoincrement'
=>
true
));
$class
->
addMappedColumn
(
'username'
,
'string'
,
50
);
}
}
\ No newline at end of file
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