Skip to content

Persist ignores Hydrator #7

@vlkolak

Description

@vlkolak

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 ?

  1. https://github.com/objective-php/gateway/blob/31746ba/src/AbstractGateway.php#L258
  2. $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]);
    }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions