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
Show 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
<?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
MetadataClass instance holds all the information (metadata) of an entity class
and it's relations.
* These informations are
needed for the proper object-relational mapping of the domain
class.
* A
ClassMetadata instance holds all the information (metadata) of an entity
and it's relations.
* These informations are
used for the proper object-relational mapping of the
class.
*
* @package Doctrine
* @author Roman Borschel <roman@code-factory.org>
* @since 1.0
*/
class
Doctrine_ClassMetadata
extends
Doctrine_Configurable
implements
Serializable
{
...
...
@@ -14,7 +34,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
*
* @var string
*/
protected
$_
domainClass
Name
;
protected
$_
entity
Name
;
/**
*
...
...
@@ -71,6 +91,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
*
* @see Doctrine_Template
* @var array $_templates
* @todo Unify under 'Behaviors'.
*/
protected
$_templates
=
array
();
...
...
@@ -79,11 +100,12 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
*
* @see Doctrine_Record_Generator
* @var array $_generators
* @todo Unify under 'Behaviors'.
*/
protected
$_generators
=
array
();
/**
* An array containing all filters attached to th
is
class.
* An array containing all filters attached to th
e
class.
*
* @see Doctrine_Record_Filter
* @var array $_filters
...
...
@@ -144,7 +166,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
*
* @var integer
*/
protected
$columnCount
;
protected
$
_
columnCount
;
/**
* Whether or not this class has default values.
...
...
@@ -160,12 +182,6 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
*/
protected
$_parser
;
/**
* Contains the mapping of the discriminator column (which discriminator value identifies
* which class). Used in Single & Class Table Inheritance.
*/
protected
$_inheritanceMap
=
array
();
/**
* Enum value arrays.
*/
...
...
@@ -191,7 +207,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
);
/**
*
*
Inheritance options.
*/
protected
$_inheritanceOptions
=
array
(
'discriminatorColumn'
=>
null
,
...
...
@@ -234,9 +250,9 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
*
* @param string $domainClassName Name of the class the metadata instance is used for.
*/
public
function
__construct
(
$
domainClass
Name
,
Doctrine_Connection
$conn
)
public
function
__construct
(
$
entity
Name
,
Doctrine_Connection
$conn
)
{
$this
->
_
domainClassName
=
$domainClass
Name
;
$this
->
_
entityName
=
$entity
Name
;
$this
->
_conn
=
$conn
;
$this
->
_parser
=
new
Doctrine_Relation_Parser
(
$this
);
$this
->
_filters
[]
=
new
Doctrine_Record_Filter_Standard
();
...
...
@@ -258,16 +274,19 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
*/
public
function
getClassName
()
{
return
$this
->
_
domainClass
Name
;
return
$this
->
_
entity
Name
;
}
/**
* @deprecated
*/
public
function
getComponentName
()
{
return
$this
->
getClassName
();
}
/**
*
W
hether a field is part of the identifier/primary key field(s).
*
Checks w
hether a field is part of the identifier/primary key field(s).
*
* @param string $fieldName The field name
* @return boolean TRUE if the field is part of the table identifier/primary key field(s),
...
...
@@ -329,31 +348,28 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
case
'enumMap'
:
$this
->
_enumMap
=
$value
;
return
;
case
'inheritanceMap'
:
$this
->
_inheritanceMap
=
$value
;
return
;
}
$this
->
_options
[
$name
]
=
$value
;
}
/**
*
*
Sets a table option.
*/
public
function
setTableOption
(
$name
,
$value
)
{
if
(
!
array_key_exists
(
$name
,
$this
->
_tableOptions
))
{
throw
new
Doctrine_
MetadataClass
_Exception
(
"Unknown table option: '
$name
'."
);
throw
new
Doctrine_
ClassMetadata
_Exception
(
"Unknown table option: '
$name
'."
);
}
$this
->
_tableOptions
[
$name
]
=
$value
;
}
/**
*
*
Gets a table option.
*/
public
function
getTableOption
(
$name
)
{
if
(
!
array_key_exists
(
$name
,
$this
->
_tableOptions
))
{
throw
new
Doctrine_
MetadataClass
_Exception
(
"Unknown table option: '
$name
'."
);
throw
new
Doctrine_
ClassMetadata
_Exception
(
"Unknown table option: '
$name
'."
);
}
return
$this
->
_tableOptions
[
$name
];
...
...
@@ -455,13 +471,16 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
}
/**
* @deprecated
*/
public
function
mapField
(
$name
,
$type
,
$length
=
null
,
$options
=
array
(),
$prepend
=
false
)
{
return
$this
->
setColumn
(
$name
,
$type
,
$length
,
$options
,
$prepend
);
}
/**
*
set
Column
*
addMapped
Column
*
* @param string $name
* @param string $type
...
...
@@ -469,10 +488,10 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
* @param mixed $options
* @param boolean $prepend Whether to prepend or append the new column to the column list.
* By default the column gets appended.
* @throws Doctrine_
Table_Exception if trying use wrongly typed parameter
* @
return voi
d
* @throws Doctrine_
ClassMetadata_Exception If trying use wrongly typed parameter.
* @
deprecate
d
*/
public
function
set
Column
(
$name
,
$type
,
$length
=
null
,
$options
=
array
(),
$prepend
=
false
)
public
function
addMapped
Column
(
$name
,
$type
,
$length
=
null
,
$options
=
array
(),
$prepend
=
false
)
{
if
(
is_string
(
$options
))
{
$options
=
explode
(
'|'
,
$options
);
...
...
@@ -557,7 +576,25 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
$this
->
_hasDefaultValues
=
true
;
}
$this
->
columnCount
++
;
$this
->
_columnCount
++
;
}
/**
* setColumn
*
* @param string $name
* @param string $type
* @param integer $length
* @param mixed $options
* @param boolean $prepend Whether to prepend or append the new column to the column list.
* By default the column gets appended.
* @throws Doctrine_Table_Exception if trying use wrongly typed parameter
* @return void
* @deprecated
*/
public
function
setColumn
(
$name
,
$type
,
$length
=
null
,
$options
=
array
(),
$prepend
=
false
)
{
return
$this
->
addMappedColumn
(
$name
,
$type
,
$length
,
$options
,
$prepend
);
}
/**
...
...
@@ -696,7 +733,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
*/
public
function
getColumnCount
()
{
return
$this
->
columnCount
;
return
$this
->
_
columnCount
;
}
/**
...
...
@@ -725,7 +762,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
unset
(
$this
->
_columns
[
$columnName
]);
return
true
;
}
$this
->
columnCount
--
;
$this
->
_
columnCount
--
;
return
false
;
}
...
...
@@ -841,8 +878,9 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
*
* @param string $name The name under which the query gets registered.
* @param string $query The DQL query.
* @todo Implementation.
*/
public
function
set
NamedQuery
(
$name
,
$query
)
public
function
add
NamedQuery
(
$name
,
$query
)
{
}
...
...
@@ -943,7 +981,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
*/
public
function
setSubclasses
(
array
$subclasses
)
{
$this
->
setOption
(
'subclasses'
,
$subclasses
);
$this
->
_options
[
'subclasses'
]
=
$subclasses
;
}
/**
...
...
@@ -957,7 +995,17 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
/**
* Checks whether the class has any persistent subclasses.
*
* @return boolean TRUE if the class has one or more persistent subclasses, FALSE otherwise.
*/
public
function
hasSubclasses
()
{
return
!
$this
->
getOption
(
'subclasses'
);
}
/**
* Gets the names of all parent classes.
*/
public
function
getParentClasses
()
{
...
...
@@ -965,7 +1013,25 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
/**
* Sets the inheritance type used by the class.
* Sets the parent class names.
*/
public
function
setParentClasses
(
array
$classNames
)
{
$this
->
_options
[
'parents'
]
=
$classNames
;
}
/**
* Checks whether the class has any persistence parent classes.
*
* @return boolean TRUE if the class has one or more persistent parent classes, FALSE otherwise.
*/
public
function
hasParentClasses
()
{
return
!
$this
->
getOption
(
'parents'
);
}
/**
* Sets the inheritance type used by the class and it's subclasses.
*
* @param integer $type
*/
...
...
@@ -978,7 +1044,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
else
if
(
$type
==
Doctrine
::
INHERITANCETYPE_TABLE_PER_CLASS
)
{
// concrete table inheritance ...
}
else
{
throw
new
Doctrine_
MetadataClass
_Exception
(
"Invalid inheritance type '
$type
'."
);
throw
new
Doctrine_
ClassMetadata
_Exception
(
"Invalid inheritance type '
$type
'."
);
}
$this
->
_inheritanceType
=
$type
;
foreach
(
$options
as
$name
=>
$value
)
{
...
...
@@ -1178,6 +1244,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
*
* @param string $template
* @return void
* @todo Unify under 'Behaviors'.
*/
public
function
getTemplate
(
$template
)
{
...
...
@@ -1188,11 +1255,17 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
return
$this
->
_templates
[
$template
];
}
/**
* @todo Unify under 'Behaviors'.
*/
public
function
hasTemplate
(
$template
)
{
return
isset
(
$this
->
_templates
[
$template
]);
}
/**
* @todo Unify under 'Behaviors'.
*/
public
function
addTemplate
(
$template
,
Doctrine_Template
$impl
)
{
$this
->
_templates
[
$template
]
=
$impl
;
...
...
@@ -1200,11 +1273,17 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
return
$this
;
}
/**
* @todo Unify under 'Behaviors'.
*/
public
function
getGenerators
()
{
return
$this
->
_generators
;
}
/**
* @todo Unify under 'Behaviors'.
*/
public
function
getGenerator
(
$generator
)
{
if
(
!
isset
(
$this
->
_generators
[
$generator
]))
{
...
...
@@ -1214,11 +1293,17 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
return
$this
->
_generators
[
$plugin
];
}
/**
* @todo Unify under 'Behaviors'.
*/
public
function
hasGenerator
(
$generator
)
{
return
isset
(
$this
->
_generators
[
$generator
]);
}
/**
* @todo Unify under 'Behaviors'.
*/
public
function
addGenerator
(
Doctrine_Record_Generator
$generator
,
$name
=
null
)
{
if
(
$name
===
null
)
{
...
...
@@ -1229,6 +1314,26 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
return
$this
;
}
/**
* loadTemplate
*
* @param string $template
* @todo Unify under 'Behaviors'.
*/
public
function
loadTemplate
(
$template
,
array
$options
=
array
())
{
$this
->
actAs
(
$template
,
$options
);
}
/**
* @todo Unify under 'Behaviors'.
*/
public
function
loadGenerator
(
Doctrine_Record_Generator
$generator
)
{
$generator
->
initialize
(
$this
->
_table
);
$this
->
addGenerator
(
$generator
,
get_class
(
$generator
));
}
/**
* unshiftFilter
*
...
...
@@ -1249,6 +1354,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
* getter for associated tree
*
* @return mixed if tree return instance of Doctrine_Tree, otherwise returns false
* @todo Belongs to the NestedSet Behavior.
*/
public
function
getTree
()
{
...
...
@@ -1269,6 +1375,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
* determine if table acts as tree
*
* @return mixed if tree return true, otherwise returns false
* @todo Belongs to the NestedSet Behavior.
*/
public
function
isTree
()
{
...
...
@@ -1286,7 +1393,9 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
/**
* Checks whether a persistent field is inherited from a superclass.
*
* @return boolean TRUE if the field is inherited, FALSE otherwise.
*/
public
function
isInheritedField
(
$fieldName
)
{
...
...
@@ -1335,10 +1444,9 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
/**
*
setTableName
*
Sets the name of the primary table the class is mapped to.
*
* @param string $tableName
* @return void
* @param string $tableName The table name.
*/
public
function
setTableName
(
$tableName
)
{
...
...
@@ -1370,7 +1478,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
/**
*
*
@todo Implementation.
*/
public
function
oneToOne
(
$targetEntity
,
$definition
)
{
...
...
@@ -1378,7 +1486,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
/**
*
*
@todo Implementation.
*/
public
function
oneToMany
(
$targetEntity
,
$definition
)
{
...
...
@@ -1386,7 +1494,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
/**
*
*
@todo Implementation.
*/
public
function
manyToOne
(
$targetEntity
,
$definition
)
{
...
...
@@ -1394,36 +1502,20 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
/**
*
*
@todo Implementation.
*/
public
function
manyToMany
(
$targetEntity
,
$definition
)
{
}
/**
* loadTemplate
*
* @param string $template
*/
public
function
loadTemplate
(
$template
,
array
$options
=
array
())
{
$this
->
actAs
(
$template
,
$options
);
}
public
function
loadGenerator
(
Doctrine_Record_Generator
$generator
)
{
$generator
->
initialize
(
$this
->
_table
);
$this
->
addGenerator
(
$generator
,
get_class
(
$generator
));
}
/**
* actAs
* loads the given plugin
*
* @param mixed $tpl
* @param array $options
* @todo Unify under 'Behaviors'.
*/
public
function
actAs
(
$tpl
,
array
$options
=
array
())
{
...
...
@@ -1432,12 +1524,9 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
$tpl
=
new
$tpl
(
$options
);
}
else
{
$className
=
'Doctrine_Template_'
.
$tpl
;
if
(
!
class_exists
(
$className
,
true
))
{
throw
new
Doctrine_Record_Exception
(
"Couldn't load plugin."
);
}
$tpl
=
new
$className
(
$options
);
}
}
...
...
@@ -1492,6 +1581,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
* Mixes a predefined behaviour into the class.
*
* @param string|object The name of the behavior or the behavior object.
* @todo Implementation.
*/
public
function
addBehavior
(
$behavior
)
{
...
...
@@ -1508,6 +1598,14 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
//Doctrine::CLASSTYPE_TRANSIENT
}
/**
* @todo Implementation.
*/
public
function
isImmutable
()
{
return
false
;
}
/**
* hasOne
* binds One-to-One aggregate relation
...
...
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