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
59be22b3
Commit
59be22b3
authored
Jul 16, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
b868b23d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
70 deletions
+35
-70
Hydrate.php
lib/Doctrine/Hydrate.php
+5
-37
Array.php
lib/Doctrine/Hydrate/Array.php
+1
-1
Record.php
lib/Doctrine/Record.php
+27
-29
Table.php
lib/Doctrine/Table.php
+2
-3
No files found.
lib/Doctrine/Hydrate.php
View file @
59be22b3
...
...
@@ -718,37 +718,6 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
{
return
$this
->
_aliasMap
;
}
/**
* mapAggregateValues
* map the aggregate values of given dataset row to a given record
*
* @param Doctrine_Record $record
* @param array $row
* @return Doctrine_Record
*/
public
function
mapAggregateValues
(
&
$record
,
array
$row
,
$alias
)
{
$found
=
false
;
// map each aggregate value
foreach
(
$row
as
$index
=>
$value
)
{
$agg
=
false
;
if
(
isset
(
$this
->
_aliasMap
[
$alias
][
'agg'
][
$index
]))
{
$agg
=
$this
->
_aliasMap
[
$alias
][
'agg'
][
$index
];
}
if
(
$agg
)
{
if
(
is_array
(
$record
))
{
$record
[
$agg
]
=
$value
;
}
else
{
$record
->
mapValue
(
$agg
,
$value
);
}
$found
=
true
;
}
}
return
$found
;
}
/**
* getCachedForm
* returns the cached form of this query for given resultSet
...
...
@@ -1001,6 +970,11 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
$alias
=
$cache
[
$key
][
'alias'
];
$field
=
$cache
[
$key
][
'field'
];
if
(
isset
(
$this
->
_aliasMap
[
$alias
][
'agg'
][
$field
]))
{
$field
=
$this
->
_aliasMap
[
$alias
][
'agg'
][
$field
];
}
$componentName
=
$map
[
'table'
]
->
getComponentName
();
if
(
isset
(
$map
[
'relation'
]))
{
$componentAlias
=
$map
[
'relation'
]
->
getAlias
();
...
...
@@ -1024,9 +998,6 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
// component changed
$element
=
$driver
->
getElement
(
$currData
[
$alias
],
$componentName
);
// map aggregate values (if any)
$this
->
mapAggregateValues
(
$element
,
$currData
[
$alias
],
$alias
);
$oneToOne
=
false
;
if
(
$alias
===
$rootAlias
)
{
...
...
@@ -1100,9 +1071,6 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
$element
=
$driver
->
getElement
(
$currData
[
$alias
],
$componentName
);
// map aggregate values (if any)
$this
->
mapAggregateValues
(
$element
,
$currData
[
$alias
],
$alias
);
$oneToOne
=
false
;
if
(
$alias
===
$rootAlias
)
{
...
...
lib/Doctrine/Hydrate/Array.php
View file @
59be22b3
...
...
@@ -43,7 +43,7 @@ class Doctrine_Hydrate_Array
}
public
function
isIdentifiable
(
array
$data
,
Doctrine_Table
$table
)
{
return
(
!
empty
(
$data
));
return
(
!
empty
(
$data
));
}
public
function
registerCollection
(
$coll
)
{
...
...
lib/Doctrine/Record.php
View file @
59be22b3
...
...
@@ -163,7 +163,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
// get the column count
$count
=
count
(
$this
->
_data
);
$this
->
_
data
=
$this
->
_filter
->
cleanData
(
$this
->
_data
);
$this
->
_
values
=
$this
->
cleanData
(
$this
->
_data
);
$this
->
prepareIdentifiers
(
$exists
);
...
...
@@ -403,6 +403,27 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
}
}
/**
* cleanData
*
* @param array $data data array to be cleaned
* @return integer
*/
public
function
cleanData
(
&
$data
)
{
$tmp
=
$data
;
$data
=
array
();
foreach
(
$this
->
getTable
()
->
getColumnNames
()
as
$name
)
{
if
(
!
isset
(
$tmp
[
$name
]))
{
$data
[
$name
]
=
self
::
$_null
;
}
else
{
$data
[
$name
]
=
$tmp
[
$name
];
}
unset
(
$tmp
[
$name
]);
}
return
$tmp
;
}
/**
* hydrate
* hydrates this object from given array
...
...
@@ -412,7 +433,9 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
*/
public
function
hydrate
(
array
$data
)
{
$this
->
_data
=
$this
->
_filter
->
cleanData
(
$data
);
$this
->
_values
=
$this
->
cleanData
(
$data
);
$this
->
_data
=
$data
;
$this
->
prepareIdentifiers
(
true
);
}
/**
...
...
@@ -541,7 +564,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$this
->
_table
->
getRepository
()
->
add
(
$this
);
$this
->
_filter
=
new
Doctrine_Record_Filter
(
$this
);
$this
->
_data
=
$this
->
_filter
->
cleanData
(
$this
->
_data
);
$this
->
cleanData
(
$this
->
_data
);
$this
->
prepareIdentifiers
(
$this
->
exists
());
...
...
@@ -631,7 +654,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
$this
->
_modified
=
array
();
$this
->
_data
=
$this
->
_filter
->
cleanData
(
$this
->
_data
);
$this
->
prepareIdentifiers
();
...
...
@@ -639,30 +661,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
return
$this
;
}
/**
* factoryRefresh
* refreshes the data from outer source (Doctrine_Table)
*
* @throws Doctrine_Record_Exception When the primary key of this record doesn't match the primary key fetched from a collection
* @return void
*/
public
function
factoryRefresh
()
{
$this
->
_data
=
$this
->
_table
->
getData
();
$old
=
$this
->
_id
;
$this
->
_data
=
$this
->
_filter
->
cleanData
(
$this
->
_data
);
$this
->
prepareIdentifiers
();
if
(
$this
->
_id
!=
$old
)
throw
new
Doctrine_Record_Exception
(
"The refreshed primary key doesn't match the one in the record memory."
,
Doctrine
::
ERR_REFRESH
);
$this
->
_state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
_modified
=
array
();
$this
->
_table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onLoad
(
$this
);
}
/**
* getTable
* returns the table object for this record
...
...
lib/Doctrine/Table.php
View file @
59be22b3
...
...
@@ -920,10 +920,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
}
if
(
$found
)
{
$this
->
data
=
array
();
$recordName
=
$this
->
getClassnameToReturn
();
$record
=
new
$recordName
(
$this
,
true
);
$this
->
data
=
array
();
return
$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