Commit 28fba54f authored by romanb's avatar romanb

Another hydrator speed improvement.

parent 5e264733
......@@ -294,6 +294,14 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
$cache[$key]['fieldName'] = $fieldName;
if ($table->isIdentifier($fieldName)) {
$cache[$key]['isIdentifier'] = true;
} else {
$cache[$key]['isIdentifier'] = false;
}
$type = $table->getTypeOfColumn($last);
if ($type == 'integer' || $type == 'string') {
$cache[$key]['isSimpleType'] = true;
} else {
$cache[$key]['isSimpleType'] = false;
}
}
......@@ -306,11 +314,15 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
$fieldName = $this->_queryComponents[$dqlAlias]['agg'][$fieldName];
}
if (isset($cache[$key]['isIdentifier'])) {
if ($cache[$key]['isIdentifier']) {
$id[$dqlAlias] .= '|' . $value;
}
if ($cache[$key]['isSimpleType']) {
$rowData[$dqlAlias][$fieldName] = $value;
} else {
$rowData[$dqlAlias][$fieldName] = $table->prepareValue($fieldName, $value);
}
if ( ! isset($nonemptyComponents[$dqlAlias]) && $value !== null) {
$nonemptyComponents[$dqlAlias] = true;
......
......@@ -1554,11 +1554,17 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*/
public function getTypeOf($fieldName)
{
$columnName = $this->getColumnName($fieldName);
if (isset($this->_columns[$columnName])) {
return $this->_columns[$columnName]['type'];
return $this->getTypeOfColumn($this->getColumnName($fieldName));
}
return false;
/**
* getTypeOfColumn
*
* @return mixed The column type or FALSE if the type cant be determined.
*/
public function getTypeOfColumn($columnName)
{
return isset($this->_columns[$columnName]) ? $this->_columns[$columnName]['type'] : false;
}
/**
......@@ -1618,6 +1624,16 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$type = $this->getTypeOf($fieldName);
switch ($type) {
case 'integer':
case 'string';
// don't do any casting here PHP INT_MAX is smaller than what the databases support
break;
case 'enum':
return $this->enumValue($fieldName, $value);
break;
case 'boolean':
return (boolean) $value;
break;
case 'array':
case 'object':
if (is_string($value)) {
......@@ -1637,15 +1653,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
}
return $value;
break;
case 'enum':
return $this->enumValue($fieldName, $value);
break;
case 'boolean':
return (boolean) $value;
break;
case 'integer':
// don't do any casting here PHP INT_MAX is smaller than what the databases support
break;
}
}
return $value;
......
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