Commit 59be22b3 authored by zYne's avatar zYne

--no commit message

--no commit message
parent b868b23d
...@@ -718,37 +718,6 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable ...@@ -718,37 +718,6 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
{ {
return $this->_aliasMap; 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 * getCachedForm
* returns the cached form of this query for given resultSet * returns the cached form of this query for given resultSet
...@@ -1001,6 +970,11 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable ...@@ -1001,6 +970,11 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
$alias = $cache[$key]['alias']; $alias = $cache[$key]['alias'];
$field = $cache[$key]['field']; $field = $cache[$key]['field'];
if (isset($this->_aliasMap[$alias]['agg'][$field])) {
$field = $this->_aliasMap[$alias]['agg'][$field];
}
$componentName = $map['table']->getComponentName(); $componentName = $map['table']->getComponentName();
if (isset($map['relation'])) { if (isset($map['relation'])) {
$componentAlias = $map['relation']->getAlias(); $componentAlias = $map['relation']->getAlias();
...@@ -1024,9 +998,6 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable ...@@ -1024,9 +998,6 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
// component changed // component changed
$element = $driver->getElement($currData[$alias], $componentName); $element = $driver->getElement($currData[$alias], $componentName);
// map aggregate values (if any)
$this->mapAggregateValues($element, $currData[$alias], $alias);
$oneToOne = false; $oneToOne = false;
if ($alias === $rootAlias) { if ($alias === $rootAlias) {
...@@ -1100,9 +1071,6 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable ...@@ -1100,9 +1071,6 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
$element = $driver->getElement($currData[$alias], $componentName); $element = $driver->getElement($currData[$alias], $componentName);
// map aggregate values (if any)
$this->mapAggregateValues($element, $currData[$alias], $alias);
$oneToOne = false; $oneToOne = false;
if ($alias === $rootAlias) { if ($alias === $rootAlias) {
......
...@@ -43,7 +43,7 @@ class Doctrine_Hydrate_Array ...@@ -43,7 +43,7 @@ class Doctrine_Hydrate_Array
} }
public function isIdentifiable(array $data, Doctrine_Table $table) public function isIdentifiable(array $data, Doctrine_Table $table)
{ {
return (! empty($data)); return ( ! empty($data));
} }
public function registerCollection($coll) public function registerCollection($coll)
{ {
......
...@@ -162,8 +162,8 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count ...@@ -162,8 +162,8 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
// get the column count // get the column count
$count = count($this->_data); $count = count($this->_data);
$this->_data = $this->_filter->cleanData($this->_data); $this->_values = $this->cleanData($this->_data);
$this->prepareIdentifiers($exists); $this->prepareIdentifiers($exists);
...@@ -403,6 +403,27 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count ...@@ -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 * hydrate
* hydrates this object from given array * hydrates this object from given array
...@@ -412,7 +433,9 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count ...@@ -412,7 +433,9 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
*/ */
public function hydrate(array $data) public function hydrate(array $data)
{ {
$this->_data = $this->_filter->cleanData($data); $this->_values = $this->cleanData($data);
$this->_data = $data;
$this->prepareIdentifiers(true); $this->prepareIdentifiers(true);
} }
/** /**
...@@ -541,7 +564,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count ...@@ -541,7 +564,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$this->_table->getRepository()->add($this); $this->_table->getRepository()->add($this);
$this->_filter = new Doctrine_Record_Filter($this); $this->_filter = new Doctrine_Record_Filter($this);
$this->_data = $this->_filter->cleanData($this->_data); $this->cleanData($this->_data);
$this->prepareIdentifiers($this->exists()); $this->prepareIdentifiers($this->exists());
...@@ -631,7 +654,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count ...@@ -631,7 +654,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
} }
$this->_modified = array(); $this->_modified = array();
$this->_data = $this->_filter->cleanData($this->_data);
$this->prepareIdentifiers(); $this->prepareIdentifiers();
...@@ -639,30 +661,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count ...@@ -639,30 +661,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
return $this; 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 * getTable
* returns the table object for this record * returns the table object for this record
......
...@@ -920,11 +920,10 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -920,11 +920,10 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
} }
if ($found) { if ($found) {
$this->data = array();
$recordName = $this->getClassnameToReturn(); $recordName = $this->getClassnameToReturn();
$record = new $recordName($this, true); $record = new $recordName($this, true);
$this->data = array();
return $record; return $record;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment