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
b6a6866b
Commit
b6a6866b
authored
Feb 13, 2008
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactorings
parent
72316541
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
125 additions
and
593 deletions
+125
-593
Doctrine.php
lib/Doctrine.php
+6
-0
ClassMetadata.php
lib/Doctrine/ClassMetadata.php
+42
-7
Connection.php
lib/Doctrine/Connection.php
+22
-16
UnitOfWork.php
lib/Doctrine/Connection/UnitOfWork.php
+28
-568
Manager.php
lib/Doctrine/Manager.php
+6
-0
Abstract.php
lib/Doctrine/Record/Abstract.php
+6
-2
Table.php
lib/Doctrine/Table.php
+1
-0
admins.php
tests/fixtures/forum/common/admins.php
+14
-0
No files found.
lib/Doctrine.php
View file @
b6a6866b
...
...
@@ -240,6 +240,7 @@ final class Doctrine
* IMMEDIATE FETCHING
* mode for immediate fetching
* @see self::ATTR_FETCHMODE
* @deprecated???
*/
const
FETCHMODE_IMMEDIATE
=
0
;
...
...
@@ -249,6 +250,7 @@ final class Doctrine
* mode for batch fetching
*
* @see self::ATTR_FETCHMODE
* @deprecated???
*/
const
FETCHMODE_BATCH
=
1
;
...
...
@@ -258,6 +260,7 @@ final class Doctrine
* mode for offset fetching
*
* @see self::ATTR_FETCHMODE
* @deprecated???
*/
const
FETCHMODE_OFFSET
=
3
;
...
...
@@ -267,6 +270,7 @@ final class Doctrine
* mode for lazy offset fetching
*
* @see self::ATTR_FETCHMODE
* @deprecated???
*/
const
FETCHMODE_LAZY_OFFSET
=
4
;
...
...
@@ -387,6 +391,7 @@ final class Doctrine
*
* mode for optimistic locking
* @see self::ATTR_LOCK
* @deprecated???
*/
const
LOCK_OPTIMISTIC
=
0
;
...
...
@@ -396,6 +401,7 @@ final class Doctrine
* mode for pessimistic locking
*
* @see self::ATTR_LOCK
* @deprecated???
*/
const
LOCK_PESSIMISTIC
=
1
;
...
...
lib/Doctrine/ClassMetadata.php
View file @
b6a6866b
...
...
@@ -36,6 +36,13 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
*/
protected
$_entityName
;
/**
* The name of the custom mapper class used for the entity class.
*
* @var string
*/
protected
$_customMapperClassName
;
/**
*
* @var Doctrine_Connection
...
...
@@ -49,9 +56,9 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
/**
* The field names of all fields that are part of the identifier/primary key
* of the described class.
* of the described
entity
class.
*
* @var array
* @var array
*/
protected
$_identifier
=
array
();
...
...
@@ -134,8 +141,9 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
/**
* An array of field names. used to look up field names from column names.
* Keys are column names and values are field names.
* This is the reverse lookup map of $_columnNames.
*
* @var array
* @var array
*/
protected
$_fieldNames
=
array
();
...
...
@@ -161,10 +169,10 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
protected
$_tree
;
/**
* Cached column count, Doctrine_Record uses this column count
in
when
* Cached column count, Doctrine_Record uses this column count when
* determining its state.
*
* @var integer
* @var integer
*/
protected
$_columnCount
;
...
...
@@ -201,8 +209,8 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
protected
$_options
=
array
(
'treeImpl'
=>
null
,
'treeOptions'
=>
null
,
'subclasses'
=>
array
(),
'queryParts'
=>
array
(),
'subclasses'
=>
array
(),
'parents'
=>
array
()
);
...
...
@@ -1589,7 +1597,32 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
/**
* Registers a custom mapper for the entity class.
*
* @param string $mapperClassName The class name of the custom mapper.
*/
public
function
setCustomMapperClass
(
$mapperClassName
)
{
if
(
!
is_subclass_of
(
$mapperClassName
,
'Doctrine_Mapper'
))
{
throw
new
Doctrine_ClassMetadata_Exception
(
"The custom mapper must be a subclass"
.
" of Doctrine_Mapper."
);
}
$this
->
_customMapperClassName
=
$mapperClassName
;
}
/**
* Gets the name of the custom mapper class used for the entity class.
*
* @return string|null The name of the custom mapper class or NULL if the entity
* class does not have a custom mapper class.
*/
public
function
getCustomMapperClass
()
{
return
$this
->
_customMapperClassName
;
}
/**
* @todo Thoughts & Implementation.
*/
public
function
setType
(
$type
)
{
...
...
@@ -1599,7 +1632,9 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
/**
* @todo Implementation.
* @todo Implementation. Immutable entities can not be updated or deleted once
* they are created. This means the entity can only be modified as long as it's
* in transient state (TCLEAN, TDIRTY).
*/
public
function
isImmutable
()
{
...
...
lib/Doctrine/Connection.php
View file @
b6a6866b
...
...
@@ -52,6 +52,7 @@ Doctrine::autoload('Doctrine_Configurable');
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Lukas Smith <smith@pooteeweet.org> (MDB2 library)
* @author Roman Borschel <roman@code-factory.org>
*/
abstract
class
Doctrine_Connection
extends
Doctrine_Configurable
implements
Countable
,
IteratorAggregate
{
...
...
@@ -63,16 +64,18 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
protected
$dbh
;
/**
* The metadata factory is used to retrieve the metadata of classes.
* The metadata factory is used to retrieve the metadata of
entity
classes.
*
* @var Doctrine_ClassMetadata_Factory
* @todo package:orm
*/
protected
$_metadataFactory
;
/**
* An array of mapper objects currently maintained by this connection.
*
* @var array
* @var array
* @todo package:orm
*/
protected
$_mappers
=
array
();
...
...
@@ -202,6 +205,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*
* @param Doctrine_Manager $manager the manager object
* @param PDO|Doctrine_Adapter_Interface $adapter database driver
* @todo Remove the dependency on the Manager for DBAL/ORM separation.
*/
public
function
__construct
(
Doctrine_Manager
$manager
,
$adapter
,
$user
=
null
,
$pass
=
null
)
{
...
...
@@ -985,7 +989,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
if
(
!
empty
(
$params
))
{
$stmt
=
$this
->
prepare
(
$query
);
$stmt
->
execute
(
$params
);
//echo "<br /><br />" . $query . "<br /><br />";
return
$stmt
->
rowCount
();
}
else
{
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
CONN_EXEC
,
$query
,
$params
);
...
...
@@ -994,7 +997,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
if
(
!
$event
->
skipOperation
)
{
$count
=
$this
->
dbh
->
exec
(
$query
);
//echo "<br /><br />" . $query . "<br /><br />";
$this
->
_count
++
;
}
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
postExec
(
$event
);
...
...
@@ -1042,6 +1044,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*
* @param mixed $name
* @return boolean
* @deprecated
* @todo package:orm
*/
public
function
hasTable
(
$name
)
{
...
...
@@ -1052,6 +1056,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* Returns the metadata for a class.
*
* @return Doctrine_Metadata
* @deprecated Use getClassMetadata()
* @todo package:orm
*/
public
function
getMetadata
(
$className
)
...
...
@@ -1080,6 +1085,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* classes.
*
* @param $driver The driver to use.
* @todo package:orm
*/
public
function
setClassMetadataDriver
(
$driver
)
{
...
...
@@ -1090,35 +1096,35 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* Gets a mapper for the specified domain class that is used to map instances of
* the class between the relational database and their object representation.
*
* @param string $entityClassName The name of the entity class.
* @return Doctrine_Mapper The mapper object.
* @todo package:orm
*/
public
function
getMapper
(
$
c
lassName
)
public
function
getMapper
(
$
entityC
lassName
)
{
if
(
isset
(
$this
->
_mappers
[
$
c
lassName
]))
{
return
$this
->
_mappers
[
$
c
lassName
];
if
(
isset
(
$this
->
_mappers
[
$
entityC
lassName
]))
{
return
$this
->
_mappers
[
$
entityC
lassName
];
}
$customMapperClass
=
$className
.
'Mapper'
;
$metadata
=
$this
->
getMetadata
(
$className
);
if
(
class_exists
(
$customMapperClass
,
$this
->
getAttribute
(
Doctrine
::
ATTR_AUTOLOAD_TABLE_CLASSES
))
&&
in_array
(
'Doctrine_Mapper_Abstract'
,
class_parents
(
$customMapperClass
)))
{
$mapper
=
new
$customMapperClass
(
$className
,
$metadata
);
$metadata
=
$this
->
getClassMetadata
(
$entityClassName
);
$customMapperClassName
=
$metadata
->
getCustomMapperClass
();
if
(
$customMapperClassName
!==
null
)
{
$mapper
=
new
$customMapperClassName
(
$entityClassName
,
$metadata
);
}
else
{
// instantiate correct mapper type
$inheritanceType
=
$metadata
->
getInheritanceType
();
if
(
$inheritanceType
==
Doctrine
::
INHERITANCETYPE_JOINED
)
{
$mapper
=
new
Doctrine_Mapper_Joined
(
$
c
lassName
,
$metadata
);
$mapper
=
new
Doctrine_Mapper_Joined
(
$
entityC
lassName
,
$metadata
);
}
else
if
(
$inheritanceType
==
Doctrine
::
INHERITANCETYPE_SINGLE_TABLE
)
{
$mapper
=
new
Doctrine_Mapper_SingleTable
(
$
c
lassName
,
$metadata
);
$mapper
=
new
Doctrine_Mapper_SingleTable
(
$
entityC
lassName
,
$metadata
);
}
else
if
(
$inheritanceType
==
Doctrine
::
INHERITANCETYPE_TABLE_PER_CLASS
)
{
$mapper
=
new
Doctrine_Mapper_TablePerClass
(
$
c
lassName
,
$metadata
);
$mapper
=
new
Doctrine_Mapper_TablePerClass
(
$
entityC
lassName
,
$metadata
);
}
else
{
throw
new
Doctrine_Connection_Exception
(
"Unknown inheritance type '
$inheritanceType
'. Can't create mapper."
);
}
}
$this
->
_mappers
[
$
c
lassName
]
=
$mapper
;
$this
->
_mappers
[
$
entityC
lassName
]
=
$mapper
;
return
$mapper
;
}
...
...
lib/Doctrine/Connection/UnitOfWork.php
View file @
b6a6866b
This diff is collapsed.
Click to expand it.
lib/Doctrine/Manager.php
View file @
b6a6866b
...
...
@@ -330,6 +330,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*
* @param array $dsn An array of dsn information
* @return array The array parsed
* @todo package:dbal
*/
public
function
parsePdoDsn
(
$dsn
)
{
...
...
@@ -367,6 +368,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*
* @param string $dsn
* @return array Parsed contents of DSN
* @todo package:dbal
*/
public
function
parseDsn
(
$dsn
)
{
...
...
@@ -599,6 +601,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
* @see Doctrine_Connection::getTable()
* @param string $componentName
* @return Doctrine_Table
* @deprecated
*/
public
function
getTable
(
$componentName
)
{
...
...
@@ -698,6 +701,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
* returns the number of opened connections
*
* @return integer
* @todo This is unintuitive.
*/
public
function
count
()
{
...
...
@@ -738,6 +742,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*
* @param string $specifiedConnections Array of connections you wish to create the database for
* @return void
* @todo package:dbal
*/
public
function
createDatabases
(
$specifiedConnections
=
array
())
{
...
...
@@ -765,6 +770,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*
* @param string $specifiedConnections Array of connections you wish to drop the database for
* @return void
* @todo package:dbal
*/
public
function
dropDatabases
(
$specifiedConnections
=
array
())
{
...
...
lib/Doctrine/Record/Abstract.php
View file @
b6a6866b
...
...
@@ -33,13 +33,15 @@ Doctrine::autoload('Doctrine_Access');
abstract
class
Doctrine_Record_Abstract
extends
Doctrine_Access
{
/**
* @param Doctrine_Table $_table reference to associated Doctrine_Table instance
* The metadata container that describes the entity class.
*
* @param Doctrine_ClassMetadata
*/
protected
$_table
;
/**
*
* @var Doctrine_Mapper
_Abstract
* @var Doctrine_Mapper
*/
protected
$_mapper
;
...
...
@@ -77,6 +79,8 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access
/**
* Returns the mapper of the entity.
*
* @return Doctrine_Mapper
*/
public
function
getMapper
()
{
...
...
lib/Doctrine/Table.php
View file @
b6a6866b
...
...
@@ -6,6 +6,7 @@
*
* @package Doctrine
* @author Roman Borschel <roman@code-factory.org>
* @todo Remove or is there use for such a class in the DBAL?
*/
class
Doctrine_Table
extends
Doctrine_Configurable
implements
Serializable
{
...
...
tests/fixtures/forum/common/admins.php
0 → 100644
View file @
b6a6866b
<?php
$fixture
=
array
(
'model'
=>
'ForumAdministrator'
,
'rows'
=>
array
(
array
(
'id'
=>
1
,
'foo'
=>
'bar'
),
array
(
'id'
=>
2
,
'foo'
=>
'bar2'
)
)
);
\ 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