func (o *Title) AddUserPersonalInfoTitles(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*UserPersonalInfoTitle) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.TitleID = o.TitleID
			if err = rel.Insert(ctx, exec, boil.Infer()); err != nil {
				return errors.Wrap(err, "failed to insert into foreign table")
			}
		} else {
			updateQuery := fmt.Sprintf(
				"UPDATE \"user_personal_info_title\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"title_id"}),
				strmangle.WhereClause("\"", "\"", 2, userPersonalInfoTitlePrimaryKeyColumns),
			)
			values := []interface{}{o.TitleID, rel.UserPersonalInfoTitleID}

			if boil.DebugMode {
				fmt.Fprintln(boil.DebugWriter, updateQuery)
				fmt.Fprintln(boil.DebugWriter, values)
			}

			if _, err = exec.ExecContext(ctx, updateQuery, values...); err != nil {
				return errors.Wrap(err, "failed to update foreign table")
			}

			rel.TitleID = o.TitleID
		}
	}

	if o.R == nil {
		o.R = &titleR{
			UserPersonalInfoTitles: related,
		}
	} else {
		o.R.UserPersonalInfoTitles = append(o.R.UserPersonalInfoTitles, related...)
	}

	for _, rel := range related {
		if rel.R == nil {
			rel.R = &userPersonalInfoTitleR{
				Title: o,
			}
		} else {
			rel.R.Title = o
		}
	}
	return nil
}
// AddUserPersonalInfoTitles adds the given related objects to the existing relationships
// of the title, optionally inserting them as new records.
// Appends related to o.R.UserPersonalInfoTitles.
// Sets related.R.Title appropriately.
AddUserPersonalInfoTitles adds the given related objects to the existing relationships
of the title, optionally inserting them as new records.
Appends related to o.R.UserPersonalInfoTitles.
Sets related.R.Title appropriately.
// AddUserPersonalInfoTitles adds the given related objects to the existing relationships // of the title optionally inserting them as new records . // Appends related to o . R . UserPersonalInfoTitles . // Sets related . R . Title appropriately .
func (o *Title) AddUserPersonalInfoTitles(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*UserPersonalInfoTitle) error {
	var err error
	for _, rel := range related {
		if insert {
			rel.TitleID = o.TitleID
			if err = rel.Insert(ctx, exec, boil.Infer()); err != nil {
				return errors.Wrap(err, "failed to insert into foreign table")
			}
		} else {
			updateQuery := fmt.Sprintf(
				"UPDATE \"user_personal_info_title\" SET %s WHERE %s",
				strmangle.SetParamNames("\"", "\"", 1, []string{"title_id"}),
				strmangle.WhereClause("\"", "\"", 2, userPersonalInfoTitlePrimaryKeyColumns),
			)
			values := []interface{}{o.TitleID, rel.UserPersonalInfoTitleID}
			if boil.DebugMode {
				fmt.Fprintln(boil.DebugWriter, updateQuery)
				fmt.Fprintln(boil.DebugWriter, values)
			}
			if _, err = exec.ExecContext(ctx, updateQuery, values...); err != nil {
				return errors.Wrap(err, "failed to update foreign table")
			}
			rel.TitleID = o.TitleID
		}
	}
	if o.R == nil {
		o.R = &titleR{
			UserPersonalInfoTitles: related,
		}
	} else {
		o.R.UserPersonalInfoTitles = append(o.R.UserPersonalInfoTitles, related...)
	}
	for _, rel := range related {
		if rel.R == nil {
			rel.R = &userPersonalInfoTitleR{
				Title: o,
			}
		} else {
			rel.R.Title = o
		}
	}
	return nil
}
func ( o * Title ) AddUserPersonalInfoTitles ( ctx context . Context , exec boil . ContextExecutor , insert bool , related ... * UserPersonalInfoTitle ) error { var err error for _ , rel := range related { if insert { rel . TitleID = o . TitleID if err = rel . Insert ( ctx , exec , boil . Infer ( ) ) ; err != nil { return errors . Wrap ( err , " " ) } } else { updateQuery := fmt . Sprintf ( " \" \" " , strmangle . SetParamNames ( " \" " , " \" " , 1 , [ ] string { " " } ) , strmangle . WhereClause ( " \" " , " \" " , 2 , userPersonalInfoTitlePrimaryKeyColumns ) , ) values := [ ] interface { } { o . TitleID , rel . UserPersonalInfoTitleID } if boil . DebugMode { fmt . Fprintln ( boil . DebugWriter , updateQuery ) fmt . Fprintln ( boil . DebugWriter , values ) } if _ , err = exec . ExecContext ( ctx , updateQuery , values ... ) ; err != nil { return errors . Wrap ( err , " " ) } rel . TitleID = o . TitleID } } if o . R == nil { o . R = & titleR { UserPersonalInfoTitles : related , } } else { o . R . UserPersonalInfoTitles = append ( o . R . UserPersonalInfoTitles , related ... ) } for _ , rel := range related { if rel . R == nil { rel . R = & userPersonalInfoTitleR { Title : o , } } else { rel . R . Title = o } } return nil }
AddUserPersonalInfoTitles adds the given related objects to the existing relationships
of the title, optionally inserting them as new records.
AddUserPersonalInfoTitles adds the given related objects to the existing relationships of the title optionally inserting them as new records .