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
ba9e4676
Commit
ba9e4676
authored
Nov 19, 2007
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
d5cc06e7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
40 deletions
+51
-40
UnitOfWork.php
lib/Doctrine/Connection/UnitOfWork.php
+41
-32
Record.php
lib/Doctrine/Hydrate/Record.php
+5
-6
Record.php
lib/Doctrine/Record.php
+4
-2
Table.php
lib/Doctrine/Table.php
+1
-0
No files found.
lib/Doctrine/Connection/UnitOfWork.php
View file @
ba9e4676
...
...
@@ -305,6 +305,9 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
return
true
;
}
/**
* @todo Description. See also the todo for deleteMultiple().
*/
public
function
deleteRecord
(
Doctrine_Record
$record
)
{
$ids
=
$record
->
identifier
();
...
...
@@ -329,46 +332,54 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
* deletes all records from the pending delete list
*
* @return void
* @todo Refactor. Maybe move to the Connection class? Sometimes UnitOfWork constructs
* queries itself and sometimes it leaves the sql construction to Connection.
* This should be changed.
*/
public
function
deleteMultiple
(
array
$records
)
{
{
foreach
(
$this
->
delete
as
$name
=>
$deletes
)
{
$record
=
false
;
$ids
=
array
();
if
(
is_array
(
$deletes
[
count
(
$deletes
)
-
1
]
->
getTable
()
->
getIdentifier
()))
{
if
(
count
(
$deletes
)
>
0
)
{
$query
=
'DELETE FROM '
.
$this
->
conn
->
quoteIdentifier
(
$deletes
[
0
]
->
getTable
()
->
getTableName
())
.
' WHERE '
;
$params
=
array
();
$cond
=
array
()
;
foreach
(
$deletes
as
$k
=>
$record
)
{
$ids
=
$record
->
identifier
();
$tmp
=
array
();
foreach
(
array_keys
(
$ids
)
as
$i
d
)
{
$tmp
[]
=
$id
.
' = ? '
;
}
$params
=
array_merge
(
$params
,
array_values
(
$ids
));
$
cond
[]
=
'('
.
implode
(
' AND '
,
$tmp
)
.
')
'
;
$ids
=
array
();
// Note: Why is the last element's table identifier checked here and then
// the table object from $deletes[0] used???
if
(
is_array
(
$deletes
[
count
(
$deletes
)
-
1
]
->
getTable
()
->
getIdentifier
())
&&
count
(
$deletes
)
>
0
)
{
$table
=
$deletes
[
0
]
->
getTable
()
;
$query
=
'DELETE FROM '
.
$this
->
conn
->
quoteIdentifier
(
$table
->
getTableName
())
.
' WHERE '
;
$params
=
array
();
$cond
=
array
();
foreach
(
$deletes
as
$k
=>
$recor
d
)
{
$ids
=
$record
->
identifier
()
;
$tmp
=
array
();
foreach
(
array_keys
(
$ids
)
as
$id
)
{
$
tmp
[]
=
$table
->
getColumnName
(
$id
)
.
' = ?
'
;
}
$query
.=
implode
(
' OR '
,
$cond
);
$this
->
conn
->
execute
(
$query
,
$params
);
$params
=
array_merge
(
$params
,
array_values
(
$ids
));
$cond
[]
=
'('
.
implode
(
' AND '
,
$tmp
)
.
')'
;
}
$query
.=
implode
(
' OR '
,
$cond
);
$this
->
conn
->
execute
(
$query
,
$params
);
}
else
{
foreach
(
$deletes
as
$k
=>
$record
)
{
$ids
[]
=
$record
->
getIncremented
();
}
// looks pretty messy. $record should be already out of scope. ugly php behaviour.
// even the php manual agrees on that and recommends to unset() the last element
// immediately after the loop ends.
$table
=
$record
->
getTable
();
if
(
$record
instanceof
Doctrine_Record
)
{
$params
=
substr
(
str_repeat
(
'?, '
,
count
(
$ids
)),
0
,
-
2
);
$query
=
'DELETE FROM '
.
$this
->
conn
->
quoteIdentifier
(
$record
->
getTable
()
->
getTableName
())
.
' WHERE '
.
$
record
->
getTable
()
->
getIdentifier
(
)
.
$
table
->
getColumnName
(
$table
->
getIdentifier
()
)
.
' IN('
.
$params
.
')'
;
$this
->
conn
->
execute
(
$query
,
$ids
);
...
...
@@ -395,15 +406,14 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
if
(
$rel
instanceof
Doctrine_Relation_ForeignKey
)
{
$saveLater
[
$k
]
=
$rel
;
}
elseif
(
$rel
instanceof
Doctrine_Relation_LocalKey
)
{
}
else
if
(
$rel
instanceof
Doctrine_Relation_LocalKey
)
{
// ONE-TO-ONE relationship
$obj
=
$record
->
get
(
$rel
->
getAlias
());
// Protection against infinite function recursion before attempting to save
if
(
$obj
instanceof
Doctrine_Record
&&
$obj
->
isModified
())
{
if
(
$obj
instanceof
Doctrine_Record
&&
$obj
->
isModified
())
{
$obj
->
save
(
$this
->
conn
);
/**
/**
Can this be removed?
$id = array_values($obj->identifier());
foreach ((array) $rel->getLocal() as $k => $field) {
...
...
@@ -472,11 +482,9 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
foreach
(
$record
->
getTable
()
->
getRelations
()
as
$fk
)
{
if
(
$fk
->
isComposite
())
{
$obj
=
$record
->
get
(
$fk
->
getAlias
());
if
(
$obj
instanceof
Doctrine_Record
&&
$obj
->
state
()
!=
Doctrine_Record
::
STATE_LOCKED
)
{
if
(
$obj
instanceof
Doctrine_Record
&&
$obj
->
state
()
!=
Doctrine_Record
::
STATE_LOCKED
)
{
$obj
->
delete
(
$this
->
conn
);
}
}
}
...
...
@@ -568,6 +576,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
return
true
;
}
/**
* inserts a record into database
*
...
...
lib/Doctrine/Hydrate/Record.php
View file @
ba9e4676
...
...
@@ -53,6 +53,7 @@ class Doctrine_Hydrate_Record extends Doctrine_Locator_Injectable
return
$coll
->
key
();
}
public
function
initRelated
(
$record
,
$name
)
{
if
(
!
is_array
(
$record
))
{
...
...
@@ -62,6 +63,7 @@ class Doctrine_Hydrate_Record extends Doctrine_Locator_Injectable
}
return
false
;
}
public
function
registerCollection
(
Doctrine_Collection
$coll
)
{
$this
->
_collections
[]
=
$coll
;
...
...
@@ -93,10 +95,12 @@ class Doctrine_Hydrate_Record extends Doctrine_Locator_Injectable
}
return
true
;
}
public
function
getNullPointer
()
{
return
self
::
$_null
;
}
public
function
getElement
(
array
$data
,
$component
)
{
if
(
!
isset
(
$this
->
_tables
[
$component
]))
{
...
...
@@ -104,14 +108,8 @@ class Doctrine_Hydrate_Record extends Doctrine_Locator_Injectable
$this
->
_tables
[
$component
]
->
setAttribute
(
Doctrine
::
ATTR_LOAD_REFERENCES
,
false
);
}
//echo "..before..";
//Doctrine::dump($data);
$this
->
_tables
[
$component
]
->
setData
(
$data
);
$record
=
$this
->
_tables
[
$component
]
->
getRecord
();
//echo "..after..";
//Doctrine::dump($record->getData());
if
(
!
isset
(
$this
->
_records
[
$record
->
getOid
()])
)
{
$record
->
clearRelated
();
...
...
@@ -120,6 +118,7 @@ class Doctrine_Hydrate_Record extends Doctrine_Locator_Injectable
return
$record
;
}
public
function
flush
()
{
// take snapshots from all initialized collections
...
...
lib/Doctrine/Record.php
View file @
ba9e4676
...
...
@@ -106,6 +106,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
/**
* @var array $_modified an array containing field names that have been modified
* @todo Better name? $_modifiedFields?
*/
protected
$_modified
=
array
();
...
...
@@ -761,7 +762,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
/**
* load
* loads all the unitialized properties from the database
* loads all the uni
ni
tialized properties from the database
*
* @return boolean
*/
...
...
@@ -790,7 +791,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$value
=
self
::
$_null
;
if
(
isset
(
$this
->
_data
[
$fieldName
]))
{
// check if the
property is null (= it
is the Doctrine_Null object located in self::$_null)
// check if the
value
is the Doctrine_Null object located in self::$_null)
if
(
$this
->
_data
[
$fieldName
]
===
self
::
$_null
&&
$load
)
{
$this
->
load
();
}
...
...
@@ -1379,6 +1380,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
* returns the value of autoincremented primary key of this object (if any)
*
* @return integer
* @todo Better name?
*/
final
public
function
getIncremented
()
{
...
...
lib/Doctrine/Table.php
View file @
ba9e4676
...
...
@@ -1215,6 +1215,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*
* @param Doctrine_Record $record record to be added
* @return boolean
* @todo Better name? registerRecord?
*/
public
function
addRecord
(
Doctrine_Record
$record
)
{
...
...
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