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
16a2370e
Commit
16a2370e
authored
May 11, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
e3b34394
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
177 deletions
+79
-177
Collection.php
draft/new-core/Collection.php
+18
-34
Hydrate.php
draft/new-core/Hydrate.php
+61
-143
No files found.
draft/new-core/Collection.php
View file @
16a2370e
...
...
@@ -31,7 +31,7 @@ Doctrine::autoload("Doctrine_Access");
* @version $Revision: 1207 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class
Doctrine_Collection2
extends
Doctrine_
Access
implements
Countable
,
IteratorAggregate
,
Serializable
class
Doctrine_Collection2
extends
Doctrine_
Collection
implements
Countable
,
IteratorAggregate
,
Serializable
{
/**
* @var array $data an array containing the data access objects of this collection
...
...
@@ -40,7 +40,7 @@ class Doctrine_Collection2 extends Doctrine_Access implements Countable, Iterato
/**
* @var Doctrine_Table $table each collection has only records of specified table
*/
protected
$table
;
protected
$
_
table
;
/**
* @var Doctrine_Record $reference collection can belong to a record
*/
...
...
@@ -75,7 +75,7 @@ class Doctrine_Collection2 extends Doctrine_Access implements Countable, Iterato
$table
=
Doctrine_Manager
::
getInstance
()
->
getTable
(
$table
);
}
$this
->
table
=
$table
;
$this
->
_
table
=
$table
;
$name
=
$table
->
getAttribute
(
Doctrine
::
ATTR_COLL_KEY
);
if
(
$name
!==
null
)
{
...
...
@@ -100,7 +100,7 @@ class Doctrine_Collection2 extends Doctrine_Access implements Countable, Iterato
*/
public
function
getTable
()
{
return
$this
->
table
;
return
$this
->
_
table
;
}
/**
* this method is automatically called when this Doctrine_Collection is serialized
...
...
@@ -139,12 +139,12 @@ class Doctrine_Collection2 extends Doctrine_Access implements Countable, Iterato
$this
->
$name
=
$values
;
}
$this
->
table
=
$connection
->
getTable
(
$this
->
table
);
$this
->
_table
=
$connection
->
getTable
(
$this
->
_
table
);
$this
->
expanded
=
array
();
$this
->
expandable
=
true
;
$name
=
$this
->
table
->
getAttribute
(
Doctrine
::
ATTR_COLL_KEY
);
$name
=
$this
->
_
table
->
getAttribute
(
Doctrine
::
ATTR_COLL_KEY
);
if
(
$name
!==
null
)
{
$this
->
keyColumn
=
$name
;
}
...
...
@@ -294,8 +294,8 @@ class Doctrine_Collection2 extends Doctrine_Access implements Countable, Iterato
*/
public
function
get
(
$key
)
{
if
(
$key
===
null
)
{
$record
=
$this
->
table
->
create
();
if
(
$key
===
null
||
!
isset
(
$this
->
data
[
$key
])
)
{
$record
=
$this
->
_
table
->
create
();
if
(
isset
(
$this
->
referenceField
))
{
$record
->
set
(
$this
->
referenceField
,
$this
->
reference
,
false
);
...
...
@@ -306,22 +306,6 @@ class Doctrine_Collection2 extends Doctrine_Access implements Countable, Iterato
return
$record
;
}
if
(
!
isset
(
$this
->
data
[
$key
]))
{
if
(
!
isset
(
$this
->
data
[
$key
]))
{
$this
->
data
[
$key
]
=
$this
->
table
->
create
();
}
if
(
isset
(
$this
->
referenceField
))
{
$value
=
$this
->
reference
->
get
(
$this
->
relation
->
getLocal
());
if
(
$value
!==
null
)
{
$this
->
data
[
$key
]
->
set
(
$this
->
referenceField
,
$value
,
false
);
}
else
{
$this
->
data
[
$key
]
->
set
(
$this
->
referenceField
,
$this
->
reference
,
false
);
}
}
}
return
$this
->
data
[
$key
];
}
...
...
@@ -331,7 +315,7 @@ class Doctrine_Collection2 extends Doctrine_Access implements Countable, Iterato
public
function
getPrimaryKeys
()
{
$list
=
array
();
$name
=
$this
->
table
->
getIdentifier
();
$name
=
$this
->
_
table
->
getIdentifier
();
foreach
(
$this
->
data
as
$record
)
{
if
(
is_array
(
$record
)
&&
isset
(
$record
[
$name
]))
{
...
...
@@ -380,7 +364,7 @@ class Doctrine_Collection2 extends Doctrine_Access implements Countable, Iterato
* @param string $key optional key for the record
* @return boolean
*/
public
function
add
(
Doctrine_Record
$record
,
$key
=
null
)
public
function
add
(
Doctrine_Record
$record
,
$key
=
null
)
{
if
(
isset
(
$this
->
referenceField
))
{
$record
->
set
(
$this
->
referenceField
,
$this
->
reference
,
false
);
...
...
@@ -424,7 +408,7 @@ class Doctrine_Collection2 extends Doctrine_Access implements Countable, Iterato
public
function
loadRelated
(
$name
=
null
)
{
$list
=
array
();
$query
=
new
Doctrine_Query
(
$this
->
table
->
getConnection
());
$query
=
new
Doctrine_Query
(
$this
->
_
table
->
getConnection
());
if
(
!
isset
(
$name
))
{
foreach
(
$this
->
data
as
$record
)
{
...
...
@@ -433,13 +417,13 @@ class Doctrine_Collection2 extends Doctrine_Access implements Countable, Iterato
$list
[]
=
$value
;
}
};
$query
->
from
(
$this
->
table
->
getComponentName
()
.
'('
.
implode
(
", "
,
$this
->
table
->
getPrimaryKeys
())
.
')'
);
$query
->
where
(
$this
->
table
->
getComponentName
()
.
'.id IN ('
.
substr
(
str_repeat
(
"?, "
,
count
(
$list
)),
0
,
-
2
)
.
')'
);
$query
->
from
(
$this
->
_table
->
getComponentName
()
.
'('
.
implode
(
", "
,
$this
->
_
table
->
getPrimaryKeys
())
.
')'
);
$query
->
where
(
$this
->
_
table
->
getComponentName
()
.
'.id IN ('
.
substr
(
str_repeat
(
"?, "
,
count
(
$list
)),
0
,
-
2
)
.
')'
);
return
$query
;
}
$rel
=
$this
->
table
->
getRelation
(
$name
);
$rel
=
$this
->
_
table
->
getRelation
(
$name
);
if
(
$rel
instanceof
Doctrine_Relation_LocalKey
||
$rel
instanceof
Doctrine_Relation_ForeignKey
)
{
foreach
(
$this
->
data
as
$record
)
{
...
...
@@ -469,7 +453,7 @@ class Doctrine_Collection2 extends Doctrine_Access implements Countable, Iterato
*/
public
function
populateRelated
(
$name
,
Doctrine_Collection
$coll
)
{
$rel
=
$this
->
table
->
getRelation
(
$name
);
$rel
=
$this
->
_
table
->
getRelation
(
$name
);
$table
=
$rel
->
getTable
();
$foreign
=
$rel
->
getForeign
();
$local
=
$rel
->
getLocal
();
...
...
@@ -501,7 +485,7 @@ class Doctrine_Collection2 extends Doctrine_Access implements Countable, Iterato
$this
->
data
[
$key
]
->
setRelated
(
$name
,
$sub
);
}
}
elseif
(
$rel
instanceof
Doctrine_Relation_Association
)
{
$identifier
=
$this
->
table
->
getIdentifier
();
$identifier
=
$this
->
_
table
->
getIdentifier
();
$asf
=
$rel
->
getAssociationFactory
();
$name
=
$table
->
getComponentName
();
...
...
@@ -541,7 +525,7 @@ class Doctrine_Collection2 extends Doctrine_Access implements Countable, Iterato
public
function
save
(
Doctrine_Connection
$conn
=
null
)
{
if
(
$conn
==
null
)
{
$conn
=
$this
->
table
->
getConnection
();
$conn
=
$this
->
_
table
->
getConnection
();
}
$conn
->
beginTransaction
();
...
...
@@ -561,7 +545,7 @@ class Doctrine_Collection2 extends Doctrine_Access implements Countable, Iterato
public
function
delete
(
Doctrine_Connection
$conn
=
null
)
{
if
(
$conn
==
null
)
{
$conn
=
$this
->
table
->
getConnection
();
$conn
=
$this
->
_
table
->
getConnection
();
}
$conn
->
beginTransaction
();
...
...
draft/new-core/Hydrate.php
View file @
16a2370e
This diff is collapsed.
Click to expand it.
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