DataMapper ORM v1.8.1 |
[eluser]benboi[/eluser]
Code: $bla = new User(); Quote:SELECT *
[eluser]WanWizard[/eluser]
I'm clueless. It doesn't get any simpler than this. You don't have a save() method in your model do you?
[eluser]benboi[/eluser]
I found it .... -.- Was a method inside my User-class which has validate as its name ..... now without it works. Thanks for your help.
[eluser]Spir[/eluser]
How would you save a data shared by a N:N relation? Let me explain: You have products and attributs for instance. Products may have 1 or N attributs but Attributs could be used with 1:N products. If you had a sorting order you end with a value to be stored when saving the relationship. Code: class Product extends DataMapper { Code: class Attribut extends DataMapper { Create a another model that will have many product and attribut? Example : Code: class Product extends DataMapper {
[eluser]WanWizard[/eluser]
[quote author="benboi" date="1307641589"]Was a method inside my User-class which has validate as its name ..... now without it works.[/quote] I should have spotted that. ![]() Yes, you have to be careful overloading Datamapper methods. The list of reserved names can be found here.
[eluser]WanWizard[/eluser]
@Spir, If I understand you correctly: You have models called Product and Attribut, in an N:M relation. They will have a $has_many to oneanother. You will need a relationship table connecting the two, called Attributs_Products, containing 3 fields: 'id', 'attribut_id' and 'product_id'. This relationship table doesn't need a model. So your first code block is correct. You make relations by loading the required objects, and then link them: Code: // get a product and an attribute If you have values that don't belong to product or attribute, but are part of the relation, you need to add these fields to the Attributs_Products table. Use the Datamapper join_fields methods to manipulate them. See the manual for some examples.
[eluser]Spir[/eluser]
Yes I first set correctly as you said and it worked but then I wanted to add some fields to that relation. I'll check about the join_fields. That's exaclty what I'm looking for! Thanks a million WanWizard for your help!
[eluser]Basketcasesoftware[/eluser]
[quote author="WanWizard" date="1307568923"]Sorry for the late response, I've been hidding in a corner feeling very ashamed... ![]() Bug (and two more introduced in the same set of changes) have been fixed. Code on bitbucket, and the downloads, have been updated.[/quote] Joining us basketcases are you? :-P
[eluser]IgnitedCoder[/eluser]
First thanks for the updates… include_related many to many made my life easy… Now for my BIG question. using get_paged… I want to do something similar to CI standard pagination. e.g. << < 1 2 3 4 > >> I’ve got the prev/next code working fine. Suggestions? Thanks, Brendan
[eluser]WanWizard[/eluser]
Not exactly sure what your question is. If you have a page number, and you've made up your mind how many rows on a page, get_paged() will give you all information you need. Just create a view partial that generates the table structure and the pagination under it, using the information from $object->paged, as described here: http://datamapper.wanwizard.eu/pages/get...#get_paged. You can also feed CI's pagination with the information from get_paged(), but you'll have to convert pages to rownumbers, as Pagination works with a row offset, and not a page number. Which can be akward, since the user can type any number in the URL, which could be a row outside the scope, or halfway on a page... |
Welcome Guest, Not a member yet? Register Sign In |