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
7b84d155
Commit
7b84d155
authored
Sep 27, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #126, #127
Ticket: 126
parent
c5747109
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
71 deletions
+53
-71
Collection.php
lib/Doctrine/Collection.php
+8
-8
Batch.php
lib/Doctrine/Collection/Batch.php
+20
-1
Hydrate.php
lib/Doctrine/Hydrate.php
+2
-1
Record.php
lib/Doctrine/Record.php
+22
-61
run.php
tests/run.php
+1
-0
No files found.
lib/Doctrine/Collection.php
View file @
7b84d155
...
...
@@ -252,9 +252,9 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
foreach
(
$this
->
getNormalIterator
()
as
$record
)
{
if
(
$value
!==
null
)
{
$record
->
rawSet
(
$this
->
reference_field
,
$valu
e
);
$record
->
set
(
$this
->
reference_field
,
$value
,
fals
e
);
}
else
{
$record
->
rawSet
(
$this
->
reference_field
,
$this
->
referenc
e
);
$record
->
set
(
$this
->
reference_field
,
$this
->
reference
,
fals
e
);
}
}
}
elseif
(
$relation
instanceof
Doctrine_Association
)
{
...
...
@@ -360,7 +360,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
if
(
!
isset
(
$offset
))
{
foreach
(
$coll
as
$record
)
{
if
(
isset
(
$this
->
reference_field
))
$record
->
rawSet
(
$this
->
reference_field
,
$this
->
referenc
e
);
$record
->
set
(
$this
->
reference_field
,
$this
->
reference
,
fals
e
);
$this
->
reference
->
addReference
(
$record
,
$this
->
relation
);
}
...
...
@@ -431,10 +431,10 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
$value
=
$this
->
reference
->
get
(
$this
->
relation
->
getLocal
());
if
(
$value
!==
null
)
{
$this
->
data
[
$key
]
->
rawSet
(
$this
->
reference_field
,
$valu
e
);
$this
->
data
[
$key
]
->
set
(
$this
->
reference_field
,
$value
,
fals
e
);
}
else
{
$this
->
data
[
$key
]
->
rawSet
(
$this
->
reference_field
,
$this
->
referenc
e
);
$this
->
data
[
$key
]
->
set
(
$this
->
reference_field
,
$this
->
reference
,
fals
e
);
}
}
}
...
...
@@ -483,7 +483,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
*/
public
function
set
(
$key
,
Doctrine_Record
$record
)
{
if
(
isset
(
$this
->
reference_field
))
$record
->
rawSet
(
$this
->
reference_field
,
$this
->
referenc
e
);
$record
->
set
(
$this
->
reference_field
,
$this
->
reference
,
fals
e
);
$this
->
data
[
$key
]
=
$record
;
}
...
...
@@ -498,7 +498,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
return
false
;
if
(
isset
(
$this
->
reference_field
))
$record
->
internalSet
(
$this
->
reference_field
,
$this
->
referenc
e
);
$record
->
set
(
$this
->
reference_field
,
$this
->
reference
,
fals
e
);
if
(
isset
(
$key
))
{
if
(
isset
(
$this
->
data
[
$key
]))
...
...
@@ -527,7 +527,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
*/
public
function
add
(
Doctrine_Record
$record
,
$key
=
null
)
{
if
(
isset
(
$this
->
reference_field
))
$record
->
rawSet
(
$this
->
reference_field
,
$this
->
referenc
e
);
$record
->
set
(
$this
->
reference_field
,
$this
->
reference
,
fals
e
);
if
(
in_array
(
$record
,
$this
->
data
))
{
return
false
;
...
...
lib/Doctrine/Collection/Batch.php
View file @
7b84d155
<?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_Collection'
);
/**
* Doctrine_Collection_Batch a collection of records,
...
...
@@ -148,7 +167,7 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
if
(
isset
(
$this
->
reference_field
))
$this
->
data
[
$key
]
->
rawSet
(
$this
->
reference_field
,
$this
->
referenc
e
);
$this
->
data
[
$key
]
->
set
(
$this
->
reference_field
,
$this
->
reference
,
fals
e
);
return
$this
->
data
[
$key
];
...
...
lib/Doctrine/Hydrate.php
View file @
7b84d155
...
...
@@ -414,7 +414,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
case
Doctrine_Relation
::
ONE_AGGREGATE
:
// one-to-one relation
$last
->
rawSet
(
$fk
->
getLocal
(),
$record
->
getIncremented
());
if
(
$fk
instanceof
Doctrine_LocalKey
)
$last
->
set
(
$fk
->
getLocal
(),
$record
->
getIncremented
(),
false
);
$last
->
initSingleReference
(
$record
,
$fk
);
...
...
lib/Doctrine/Record.php
View file @
7b84d155
...
...
@@ -682,72 +682,22 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
return
$this
->
references
[
$name
];
}
/**
* internalSet
*
* @param mixed $name
* @param mixed $value
*/
final
public
function
internalSet
(
$name
,
$value
)
{
if
(
$value
===
null
)
$value
=
self
::
$null
;
$this
->
data
[
$name
]
=
$value
;
}
/**
* rawSet
* doctrine uses this function internally, not recommended for developers
*
* rawSet() works in very same same way as set() with an exception that
* 1. it cannot be used for setting references
* 2. it cannot load uninitialized fields
*
* @param mixed $name name of the property or reference
* @param mixed $value value of the property or reference
*/
final
public
function
rawSet
(
$name
,
$value
)
{
$name
=
strtolower
(
$name
);
if
(
$value
instanceof
Doctrine_Record
)
$id
=
$value
->
getIncremented
();
if
(
isset
(
$id
))
$value
=
$id
;
if
(
isset
(
$this
->
data
[
$name
]))
{
if
(
$this
->
data
[
$name
]
===
self
::
$null
)
{
if
(
$this
->
data
[
$name
]
!==
$value
)
{
switch
(
$this
->
state
)
:
case
Doctrine_Record
::
STATE_CLEAN
:
$this
->
state
=
Doctrine_Record
::
STATE_DIRTY
;
break
;
case
Doctrine_Record
::
STATE_TCLEAN
:
$this
->
state
=
Doctrine_Record
::
STATE_TDIRTY
;
endswitch
;
}
}
if
(
$this
->
state
==
Doctrine_Record
::
STATE_TCLEAN
)
$this
->
state
=
Doctrine_Record
::
STATE_TDIRTY
;
if
(
$value
===
null
)
$value
=
self
::
$null
;
$this
->
data
[
$name
]
=
$value
;
$this
->
modified
[]
=
$name
;
}
}
/**
* set
* method for altering properties and Doctrine_Record references
* if the load parameter is set to false this method will not try to load uninitialized record data
*
* @param mixed $name name of the property or reference
* @param mixed $value value of the property or reference
* @param boolean $load whether or not to refresh / load the uninitialized record data
*
* @throws Doctrine_Record_Exception if trying to set a value for unknown property / related component
* @throws Doctrine_Record_Exception if trying to set a value of wrong type for related component
*
* @return Doctrine_Record
*/
public
function
set
(
$name
,
$val
ue
)
{
public
function
set
(
$name
,
$value
,
$load
=
tr
ue
)
{
$lower
=
strtolower
(
$name
);
if
(
isset
(
$this
->
data
[
$lower
]))
{
...
...
@@ -759,7 +709,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$value
=
$id
;
}
$old
=
$this
->
get
(
$lower
,
false
);
if
(
$load
)
$old
=
$this
->
get
(
$lower
,
false
);
else
$old
=
$this
->
data
[
$lower
];
if
(
$old
!==
$value
)
{
...
...
@@ -773,7 +726,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
modified
[]
=
$lower
;
switch
(
$this
->
state
)
:
case
Doctrine_Record
::
STATE_CLEAN
:
case
Doctrine_Record
::
STATE_PROXY
:
$this
->
state
=
Doctrine_Record
::
STATE_DIRTY
;
break
;
case
Doctrine_Record
::
STATE_TCLEAN
:
...
...
@@ -947,7 +899,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
return
$a
;
}
/**
* count
* this class implements countable interface
*
* @return integer the number of columns
*/
public
function
count
()
{
...
...
@@ -955,13 +909,15 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
/**
* alias for count()
*
* @return integer
*/
public
function
getColumnCount
()
{
return
$this
->
count
();
}
/**
* toArray
* returns record as an array
* returns
the
record as an array
*
* @return array
*/
...
...
@@ -978,7 +934,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
return
$a
;
}
/**
* checks if record has data
* exists
* returns true if this record is persistent, otherwise false
*
* @return boolean
*/
public
function
exists
()
{
...
...
@@ -1475,13 +1433,16 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* merges this record with an array of values
*
* @param array $values
* @return void
*/
public
function
merge
(
array
$values
)
{
foreach
(
$this
->
table
->
getColumnNames
()
as
$value
)
{
try
{
if
(
isset
(
$values
[
$value
]))
$this
->
set
(
$value
,
$values
[
$value
]);
}
catch
(
Exception
$e
)
{
}
}
catch
(
Exception
$e
)
{
// silence all exceptions
}
}
}
/**
...
...
tests/run.php
View file @
7b84d155
...
...
@@ -95,6 +95,7 @@ $test->addTestCase(new Doctrine_EventListener_Chain_TestCase());
$test
->
addTestCase
(
new
Doctrine_DataDict_Sqlite_TestCase
());
$test
->
addTestCase
(
new
Doctrine_BooleanTestCase
());
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
...
...
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