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
{
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) {
......
......@@ -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)
{
......
......@@ -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
......
......@@ -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;
}
......
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