In the ideal case, the Entity will be a one-to-one self-evident, self-explanatory match with the database table collection.
Unless the column naming is not practical : in that case a Zend\Hydrator\NamingStrategy\NamingStrategyInterface implementation could be used.
Unless the column typing is not practical : in that case a Zend\Hydrator\Strategy\StrategyInterface could be used.
It is used to hydrate the entity on Fetch 1, but not to extract the entity on persist 2
Could we extract everything through the hydrator in persist ?
- https://github.com/objective-php/gateway/blob/31746ba/src/AbstractGateway.php#L258
|
$fields = array_diff($entity->getEntityFields(), $colsToRemove); |
|
|
|
$query->cols($fields); |
|
|
|
foreach ($fields as $field) { |
|
$value = $entity[$field]; |
|
if ($value instanceof \DateTime) { |
|
$query->bindValue($field, $value->format('Y-m-d H:i:s')); |
|
} else { |
|
$query->bindValue($field, $entity[$field]); |
|
} |
|
} |
In the ideal case, the Entity will be a one-to-one self-evident, self-explanatory match with the database
tablecollection.Unless the column naming is not practical : in that case a Zend\Hydrator\NamingStrategy\NamingStrategyInterface implementation could be used.
Unless the column typing is not practical : in that case a Zend\Hydrator\Strategy\StrategyInterface could be used.
It is used to hydrate the entity on Fetch 1, but not to extract the entity on persist 2
Could we extract everything through the hydrator in persist ?
mysql-gateway/src/AbstractMySqlGateway.php
Lines 147 to 158 in 9cb3297