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
90bd728d
Commit
90bd728d
authored
Sep 01, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for collection key mapping
parent
da9d179d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
9 deletions
+45
-9
Basic Components - Collection - Key mapping.php
manual/codes/Basic Components - Collection - Key mapping.php
+31
-0
Basic Components - Collection - Key mapping.php
manual/docs/Basic Components - Collection - Key mapping.php
+3
-0
documentation.php
manual/documentation.php
+11
-9
No files found.
manual/codes/Basic Components - Collection - Key mapping.php
0 → 100644
View file @
90bd728d
<?php
// mapping id column
$user
=
new
User
();
$user
->
setAttribute
(
Doctrine
::
ATTR_COLL_KEY
,
'id'
);
// now user collections will use the values of
// id column as element indexes
$users
=
$user
->
getTable
()
->
findAll
();
foreach
(
$users
as
$id
=>
$user
)
{
print
$id
.
$user
->
name
;
}
// mapping name column
$user
=
new
User
();
$user
->
setAttribute
(
Doctrine
::
ATTR_COLL_KEY
,
'name'
);
// now user collections will use the values of
// name column as element indexes
$users
=
$user
->
getTable
()
->
findAll
();
foreach
(
$users
as
$name
=>
$user
)
{
print
$name
.
$user
->
type
;
}
?>
manual/docs/Basic Components - Collection - Key mapping.php
0 → 100644
View file @
90bd728d
Sometimes
you
may
not
want
to
use
normal
indexing
for
collection
elements
.
For
example
in
some
cases
mapping
primary
keys
as
collection
keys
might
be
useful
.
The
following
example
demonstrates
how
this
can
be
achieved
.
manual/documentation.php
View file @
90bd728d
...
...
@@ -138,6 +138,7 @@ $menu = array("Getting started" =>
"Saving the collection"
,
"Deleting collection"
,
//"Fetching strategies",
"Key mapping"
,
"Loading related records"
,
"Collection expanding"
,
),
...
...
@@ -366,12 +367,12 @@ $menu = array("Getting started" =>
if
(
!
file_exists
(
"docs/
$title
-
$k
-
$v2
.php"
))
{
$missing
[
0
]
++
;
$str
.=
" [ <font color='red'>doc</font> ] "
;
//
touch("docs/$title - $k - $v2.php");
touch
(
"docs/
$title
-
$k
-
$v2
.php"
);
}
if
(
!
file_exists
(
"codes/
$title
-
$k
-
$v2
.php"
))
{
$missing
[
1
]
++
;
$str
.=
" [ <font color='red'>code</font> ] "
;
//
touch("codes/$title - $k - $v2.php");
touch
(
"codes/
$title
-
$k
-
$v2
.php"
);
}
...
...
@@ -448,27 +449,28 @@ $menu = array("Getting started" =>
if
(
isset
(
$ex
[
1
]))
{
$name
=
implode
(
" - "
,
$stack
);
print
"<
b class='title'>"
.
$paths
[
$curr
]
.
"</b
><hr>"
;
print
"<
a name='
$path
'><b class='title'>"
.
$paths
[
$curr
]
.
"</b></a
><hr>"
;
$n
=
$numbers
;
$o
=
$paths
[
$n
[
0
]];
$
s
=
implode
(
"."
,
array
(
$n
[
0
],
$n
[
1
]));
$o2
=
$paths
[
$
s
];
$
numpath
=
implode
(
"."
,
array
(
$n
[
0
],
$n
[
1
]));
$o2
=
$paths
[
$
numpath
];
$value
=
$menu
[
$o
];
if
(
!
is_array
(
$value
))
if
(
!
is_array
(
$value
))
exit
;
if
(
in_array
(
$o2
,
$value
))
{
render_block
(
$name
);
}
else
{
}
else
{
$value
=
$menu
[
$o
][
$o2
];
if
(
is_array
(
$value
))
{
foreach
(
$value
as
$k
=>
$title
)
{
print
"<br \><b class='title'>"
.
$title
.
"</b><hr style='height: 1px' \>"
;
$numpath2
=
$numpath
.
'.'
.
(
$k
+
1
);
print
"<br \><a name='"
.
$numpath2
.
"'><b class='title'>"
.
$title
.
"</b></a><hr style='height: 1px' \>"
;
$s
=
$name
.
" - "
.
$title
;
...
...
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