rtyshyk
rtyshyk

Reputation: 971

doctrine 2 persist object

I have object with relation, and want save it, but I have only id and don't want get object from database.

When I persist, I have this error:

Warning: spl_object_hash() expects parameter 1 to be object, integer given

I think need use DataTransformers? Сan someone tell me how to use it?

Upvotes: 2

Views: 2695

Answers (1)

AlterPHP
AlterPHP

Reputation: 12717

Use EntityManager::getReference($entityName, $id) to get a reference to the related record.

Read the getReference doc.

Upvotes: 4

Related Questions