spotorm / spot2

Spot v2.x DataMapper built on top of Doctrine's Database Abstraction Layer
http://phpdatamapper.com
BSD 3-Clause "New" or "Revised" License
601 stars 101 forks source link

CRUD and Relationship #14

Closed harikt closed 10 years ago

harikt commented 10 years ago

Hi,

I was looking the CRUD docs http://phpdatamapper.com/docs/crud/ .

I wonder how you handle relationships on save.

Better example of handling relationship on save may help.

vlucas commented 10 years ago

Relationships are currently not handled at all on save. You have to manually save any related objects.

I should at least make a note of this in the docs, so thank you for bringing that to my attention.

There was a long discussion about this in Spot v1 and even code in a new branch implementing a save with nested arrays, but it ultimately never got merged into master. I am willing to consider adding this for Spot v2 - it's just a question of nailing down all the details and syntax so the save behavior is not surprising or unexpected.

vlucas commented 10 years ago

I just added a section with the heading "Saving Relations" at the bottom of the CRUD page.

harikt commented 10 years ago

ok. Thanks.

hkdobrev commented 10 years ago

This is the only thing stopping me from using your ORM. I think it is a must, especially for adoption from inexperienced developers.

I have used such feature in Jam (Kohana-dependant ActiveRecord) and Harp (PHP 5.4+ DataMapper in development).

I think an issue should be opened for this so interface and implementation could be discussed. What do you think?

tuupola commented 10 years ago

Not a showstopper but I agree it would save writing several lines of code. Harp looks interesting btw.