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
2f85c85c
Commit
2f85c85c
authored
Aug 11, 2007
by
nightfreak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added the method refreshRelated() to Doctrine_Record
parent
f92cd777
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
Record.php
lib/Doctrine/Record.php
+20
-0
RecordTestCase.php
tests/RecordTestCase.php
+17
-0
No files found.
lib/Doctrine/Record.php
View file @
2f85c85c
...
...
@@ -669,6 +669,26 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
return
$this
;
}
/**
* refresh
* refres data of related objects from the database
*
* @param string $name name of a related component.
* if set, this method only refreshes the specified related component
*/
public
function
refreshRelated
(
$name
=
null
)
{
if
(
is_null
(
$name
))
{
foreach
(
$this
->
_table
->
getRelations
()
as
$rel
)
{
$this
->
_references
[
$rel
->
getAlias
()]
=
$rel
->
fetchRelatedFor
(
$this
);
}
}
else
{
$rel
=
$this
->
_table
->
getRelation
(
$name
);
$this
->
_references
[
$name
]
=
$rel
->
fetchRelatedFor
(
$this
);
}
}
/**
* getTable
* returns the table object for this record
...
...
tests/RecordTestCase.php
View file @
2f85c85c
...
...
@@ -39,6 +39,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
$this
->
tables
[]
=
'fieldNameTest'
;
$this
->
tables
[]
=
'GzipTest'
;
$this
->
tables
[]
=
'Book'
;
$this
->
tables
[]
=
'EntityAddress'
;
parent
::
prepareTables
();
}
...
...
@@ -869,5 +870,21 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
$user
=
$this
->
connection
->
getTable
(
"User"
)
->
find
(
4
);
$this
->
assertTrue
(
$user
->
getIterator
()
instanceof
ArrayIterator
);
}
public
function
testRefreshRelated
()
{
$user
=
$this
->
connection
->
getTable
(
"User"
)
->
find
(
4
);
$user
->
Address
[
0
]
->
address
=
"Address #1"
;
$user
->
Address
[
1
]
->
address
=
"Address #2"
;
$user
->
save
();
$this
->
assertEqual
(
count
(
$user
->
Address
),
2
);
Doctrine_Query
::
create
()
->
delete
()
->
from
(
'EntityAddress'
)
->
where
(
'user_id = ? AND address_id = ?'
,
array
(
$user
->
id
,
$user
->
Address
[
1
]
->
id
))
->
execute
();
$user
->
refreshRelated
(
'Address'
);
$this
->
assertEqual
(
count
(
$user
->
Address
),
1
);
Doctrine_Query
::
create
()
->
delete
()
->
from
(
'EntityAddress'
)
->
where
(
'user_id = ? AND address_id = ?'
,
array
(
$user
->
id
,
$user
->
Address
[
0
]
->
id
))
->
execute
();
$user
->
refreshRelated
();
$this
->
assertEqual
(
count
(
$user
->
Address
),
0
);
}
}
?>
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