Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist ignores Hydrator #7

Open
vlkolak opened this issue Sep 22, 2017 · 0 comments · May be fixed by #9
Open

Persist ignores Hydrator #7

vlkolak opened this issue Sep 22, 2017 · 0 comments · May be fixed by #9

Comments

@vlkolak
Copy link

vlkolak commented Sep 22, 2017

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]);
    }
    }
@vlkolak vlkolak changed the title Persist ignore Hydrator Persist ignores Hydrator Sep 22, 2017
@vlkolak vlkolak linked a pull request Oct 2, 2017 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant