Multi Insert

A place for users and developers of the Xataface to discuss and receive support.

Multi Insert

Postby jmboettger » Thu May 03, 2012 12:22 pm

Hi there,

i'm still trying to insert more than one row at once in a join table (user user2course course). For example adding many users to one Course. If i try to solve it with a sql query selecting
Code: Select all
__sql__ ="SELECT * FROM user2cource WHERE courseID = '$courseID'"
it shows a advmultiselect list but justs adds one of the selected records.

Any Ideas?

Thanks and best Regards

Jakob
jmboettger
 
Posts: 8
Joined: Wed May 02, 2012 6:35 am

Re: Multi Insert

Postby camt » Fri May 04, 2012 2:57 am

Hi Jakob, have you had a look at the grid widget at all?
This should do what you want - add multiple users to a relationship in one form
http://xataface.com/wiki/grid
camt
 
Posts: 17
Joined: Wed Jan 04, 2012 9:28 am

Re: Multi Insert

Postby jmboettger » Fri May 04, 2012 11:40 am

Thanks that looks Brilliant. Indeed i did't look at this widget. Now i just have the Problem, that it does not add existing records, instead it creates new ones.
I got three tables

First one
User
columns
UserID
Name
Street

Second one
User2Course
columns
UserID
CourseID

Third one
Course
columns
CourseID
Title
Date

These Three Tables are referenced with a M:N relationship.

Now i implemented the Grid Widget at the Course Table with the Relationship
Code: Select all
[Teilnehmer]
User.UserID = User2Course.UserID
User2Course.CourseID = "$CourseID"


If i try adding users to Courses it always creates new ones instead of adding existing records.

Any Ideas?

Thanks

and Best Regards Jakob
jmboettger
 
Posts: 8
Joined: Wed May 02, 2012 6:35 am

Re: Multi Insert

Postby shannah » Mon May 07, 2012 11:41 am

It is sometimes easier to create a "dummy" relationship that is one-to-many that goes from the source table to the join table only (doesn't go all the way to the destination table). Use this relationship with the grid widget and use the lookup widget on the id column in the join table so that each row of the grid widget will just have a lookup widget, whose widget:table directive is the destination table of the m:n relationship.

Since this is a dummy relationship, you will want to hide it from the relationship tabs:
Code: Select all
action:condition="false"


-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 14 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved