Welcome Guest, Not a member yet? Register   Sign In
datamapper many to many
#1

[eluser]bralens[/eluser]
Code:
$categories = new Category();
$categories->where('public', 1)->get();

$post = new Post();
$post->title = $this->input->post('title');
$post->save($categories->all);

This code check if in join_Categories_Posts table already exists relation, but don't make new one if there is no relation.
#2

[eluser]WanWizard[/eluser]
With DataMapper 1.8.2 (on CI 2.0.2) I can not reproduce that.

When I execute the exact same code, the new post record is created, and the id of the new post record is used to insert the relation to all selected categories in the categories_posts table.

You're installation is up to date? Your models are defined correctly (as in defined BOTH ways)?
#3

[eluser]bralens[/eluser]
Yup, models are defined correctly.
I use 3.0-dev version? link
I think i have 2.1.0 version.
#4

[eluser]bralens[/eluser]
I downloaded CI reactor 2.0.2 version and changed system folders, but no result, it still do the same thing...
#5

[eluser]WanWizard[/eluser]
And which version of Datamapper?

Maybe the save fails, check the return code of $post->save().
#6

[eluser]bralens[/eluser]
DMZ version: 1.8.2.
No $post->save works fine Smile
If i use $post->save($categories->all) it saves new $post, checks if there is relation in join table, but won't make them if needed Sad
#7

[eluser]WanWizard[/eluser]
Well, it does over here.

So, what do your models look like, and the database dump of all three tables? PM me with a zip if you don't want to post them. Then I can exactly replicate your case here...




Theme © iAndrew 2016 - Forum software by © MyBB