Another hydrator speed improvement.
This commit is contained in:
parent
5e26473340
commit
28fba54f4a
@ -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;
|
||||
}
|
||||
|
||||
$rowData[$dqlAlias][$fieldName] = $table->prepareValue($fieldName, $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 false;
|
||||
return $this->getTypeOfColumn($this->getColumnName($fieldName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user