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
1ab5a4fc
Commit
1ab5a4fc
authored
Sep 28, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored Doctrine_Record, added license to LocalKey class
parent
88ef777f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
29 deletions
+47
-29
Hydrate.php
lib/Doctrine/Hydrate.php
+6
-9
LocalKey.php
lib/Doctrine/LocalKey.php
+37
-2
Record.php
lib/Doctrine/Record.php
+4
-18
No files found.
lib/Doctrine/Hydrate.php
View file @
1ab5a4fc
...
...
@@ -388,10 +388,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
unset
(
$tmp
);
$fk
=
$this
->
tables
[
$pointer
]
->
getRelation
(
$alias
);
$last
=
$prev
[
$pointer
]
->
getLast
();
switch
(
$fk
->
getType
())
:
case
Doctrine_Relation
::
ONE_COMPOSITE
:
case
Doctrine_Relation
::
ONE_AGGREGATE
:
if
(
$fk
->
isOneToOne
())
{
// one-to-one relation
if
(
$fk
instanceof
Doctrine_LocalKey
)
...
...
@@ -400,9 +397,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
$last
->
set
(
$fk
->
getAlias
(),
$record
);
$prev
[
$name
]
=
$record
;
break
;
default
:
}
else
{
// one-to-many relation or many-to-many relation
if
(
!
$last
->
hasReference
(
$alias
))
{
...
...
@@ -416,7 +411,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
}
$last
->
addReference
(
$record
,
$fk
);
endswitch
;
}
}
}
...
...
@@ -462,7 +457,9 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
return
$coll
;
}
/**
* hasEmptyIdentifier
* isIdentifiable
* returns whether or not a given data row is identifiable (it contains
* all id fields specified in the second argument)
*
* @param array $row
* @param mixed $ids
...
...
lib/Doctrine/LocalKey.php
View file @
1ab5a4fc
<?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.com>.
*/
Doctrine
::
autoload
(
'Doctrine_Relation'
);
/**
* Local Key
* Doctrine_LocalKey
* This class represents a local key relation
*
* @author Konsta Vesterinen
* @license LGPL
* @package Doctrine
*/
class
Doctrine_LocalKey
extends
Doctrine_Relation
{
}
class
Doctrine_LocalKey
extends
Doctrine_Relation
{
public
function
fetch
(
$id
=
null
)
{
if
(
empty
(
$id
))
return
$this
->
table
->
create
();
else
{
$record
=
$this
->
table
->
find
(
$id
);
return
(
$record
!==
false
)
?
$record
:
$this
->
table
->
create
();
}
}
}
lib/Doctrine/Record.php
View file @
1ab5a4fc
...
...
@@ -1242,34 +1242,20 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$id
=
$this
->
get
(
$local
);
if
(
$fk
instanceof
Doctrine_LocalKey
)
{
if
(
empty
(
$id
))
{
$this
->
references
[
$name
]
=
$table
->
create
();
$this
->
set
(
$fk
->
getLocal
(),
$this
->
references
[
$name
]);
}
else
{
$record
=
$table
->
find
(
$id
);
if
(
$record
!==
false
)
$this
->
references
[
$name
]
=
$record
;
else
$this
->
references
[
$name
]
=
$table
->
create
();
//$this->set($fk->getLocal(),$this->references[$name]);
}
$this
->
references
[
$name
]
=
$fk
->
fetch
(
$id
);
$this
->
set
(
$fk
->
getLocal
(),
$this
->
references
[
$name
],
false
);
}
elseif
(
$fk
instanceof
Doctrine_ForeignKey
)
{
if
(
empty
(
$id
))
{
$this
->
references
[
$name
]
=
$table
->
create
();
$this
->
references
[
$name
]
->
set
(
$fk
->
getForeign
(),
$this
);
}
else
{
$dql
=
"FROM "
.
$table
->
getComponentName
()
.
" WHERE "
.
$table
->
getComponentName
()
.
"."
.
$fk
->
getForeign
()
.
" = ?"
;
$coll
=
$graph
->
query
(
$dql
,
array
(
$id
));
$this
->
references
[
$name
]
=
$coll
[
0
];
$this
->
references
[
$name
]
->
set
(
$fk
->
getForeign
(),
$this
);
}
$this
->
references
[
$name
]
->
set
(
$fk
->
getForeign
(),
$this
);
}
}
else
{
...
...
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