spadefoot / kohana-orm-leap

An ORM module for the Kohana PHP framework that is designed to work with all major databases.
http://spadefoot.github.io/kohana-orm-leap/
100 stars 25 forks source link

Setting relationships: is possible? examples? #46

Closed rdlu closed 12 years ago

rdlu commented 12 years ago

First, thanks for this amazing orm. :)

But I'm struggling to discover how to set relationships before saving the model.

What kind of types are accepted (array of models, array of primary ids like Sprig)

I've tried to figuring out looking on 'function __set'@/classes/base/db/orm/model.php (and some other places too) with no luck.

bluesnowman commented 12 years ago

Have you taken a look at http://orm.spadefootcode.com/tutorials/using-a-model/

rdlu commented 12 years ago

About "take a look", yes, every part of manual. About my question, no, the referred chapter doesn't contain the answer.

So let me rephrase: Is there a analog function, or analog behavior to "has", "add" and "remove" of this doc: "http://kohanaframework.org/3.2/guide/orm/relationships"? Or the same behavior of the exemplified array, "relate" and "unrelate" functions of Sprig manual "https://github.com/sittercity/sprig#many-to-many-relations"?

bluesnowman commented 12 years ago

As for mapping relations, you can checkout the following tutorial: http://orm.spadefootcode.com/tutorials/mapping-a-model/#relations

With respect to adding and removing relations, I will look at adding this feature to the project. It doesn't look too hard to do. Do you already have these functions written? If you do, you can send me a pull request; otherwise, I will see what I can do to implement them.

Thanks for the inquiry. We really appreciate your input and will happy to add such functionality. I will get back to you shortly.