On 9 March 2014 16:35, Nima Sadjadi <[email protected]> wrote:
>
> when I want to update a row by identifier:
>
>
> $something = $em->find('Entities\Something', $_POST['id']);
> $something->setFields($_POST, array('blah'));
> then flush... It works fine.
>
> But findBy is not valid for entity, but only for repository.
>
Not sure about what kind of operation you consider for "entity" and
"repository" here - mind writing down both examples and the results?
>
> $something =
> $em->getRepository('Repository\Something')->findBy(array('productId' =>
> $_POST['productId']));
> it seems I have a repository file as Something.php and it seems something
> is found but how can I set fields to be updated? just adding a function
> setFields() in repository file like the one in entity file, will not work...
>
The repository just fetches entities, it shouldn't really manipulate them.
> $something->setFields($_POST, array('blah'));
>
This is obviously an entity method
Marco Pivetta
http://twitter.com/Ocramius
http://ocramius.github.com/
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.