Welcome Guest, Not a member yet? Register   Sign In
DataMapper | Unknown column 'User' in 'field list'
#6

[eluser]WanWizard[/eluser]
You have a has_one from posts -> users, and a has_many from users -> posts. Normally, this means the foreign keys are part of the posts table, and no relation table is needed.

Get rid of the posts_users table, and add 'creator_id' and 'editor_id' to the posts table.

Code:
$p = new Post();
$p->title = "Test new post with creator 1 and editor 2";

$u = new User(1);
$p->save_creator($u); // create the post with creator id 1

$u = new User(2);
$p->save_editor($u);  // update the post with editor id 2

Also, the "other_field" value in the advanced relationship is used to be able to map the relation from the other side, if that is defined different from the class name.

You do that correct here, but then you use these as column names in the relationship table, which is not where they are used. If you insist on using a relationship table, you will have to use the 'join_self_as' and 'join_other_as' fields to define the foreign key colums in the relationship table.


Messages In This Thread
DataMapper | Unknown column 'User' in 'field list' - by El Forum - 03-16-2012, 01:12 PM
DataMapper | Unknown column 'User' in 'field list' - by El Forum - 03-16-2012, 03:26 PM
DataMapper | Unknown column 'User' in 'field list' - by El Forum - 03-16-2012, 04:21 PM
DataMapper | Unknown column 'User' in 'field list' - by El Forum - 03-17-2012, 03:46 AM
DataMapper | Unknown column 'User' in 'field list' - by El Forum - 03-17-2012, 03:37 PM
DataMapper | Unknown column 'User' in 'field list' - by El Forum - 03-18-2012, 03:33 AM
DataMapper | Unknown column 'User' in 'field list' - by El Forum - 03-21-2012, 03:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB