Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6236383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:50:41+00:00 2026-05-24T10:50:41+00:00

in my very rare case, i must create 2 many-to-many relations on the same

  • 0

in my very “rare” case, i must create 2 many-to-many relations on the same tables.
I explain:
I have a two tables ; Monitor and Server having many to many rel the intermediate table will be called “Benchmark”. But in the same time i have to have another intermediate table which can allow me to couple a url from a monitor to several ip’s from the servers (the table is called “Url_ip”)
So here is what i’ve done :

    Monitor:
      tableName: monitor
      actAs:
        Timestampable: ~
      columns:
        id : {type: integer(4), primary: true, autoincrement: true}
        label: {type: string(45)}
        url: {type: string(80)}
        frequency: {type: integer}
        timeout: {type: integer}
        method: {type: enum, values: [GET, POST]}
        parameters: {type: string(255)}
      relations:
        Groups:
          class: Groups
          local: monitor_id
          foreign: sf_guard_group_id
          refClass: Alert
        Server:
          class: Server
          local: monitor_id
          foreign: server_id
          refClass: Benchmark
        Server2:
          class: Server
          local: monitor_id
          foreign: server_id
          foreignAlias: Ips
          refClass: Url_ip

    Url_ip:
      actAs:
        Timestampable: ~
      columns:
        monitor_id: { type: integer(4), primary: true }
        server_id: { type: integer(4), primary: true }
      relations:
        Monitor:
          foreignAlias: IpUrls
        Server:
          foreignAlias: IpUrls       

    Benchmark:
      tableName: benchmark
      actAs:
        Timestampable: ~
      columns:
        monitor_id: { type: integer(4), primary: true }
        server_id: { type: integer(4), primary: true }
        connexionTime: {type: string(45)}
        executionTime: {type: string(45)}
        responseTime: {type: string(45)}
        responseCode: {type: string(45)}
        responseMessage: {type: string(45)}
      relations:
        Monitor:
          foreignAlias: ServerMonitors
        Server:
          foreignAlias: ServerMonitors



    Server:
      tableName: server
      actAs:
        TimeStampable: ~
      columns:
        id : {type: integer(4), primary: true,autoincrement: true}
        name: {type: string(255)}
        ip: {type: string(45)}
      relations:
        Monitor:
          class: Monitor
          local: server_id
          foreign: monitor_id
          refClass: Benchmark
        Monitor2:
          class: Monitor
          foreignAlias: monitors
          local: server_id
          foreign: monitor_id
          refClass: Url_ip


Alert:
  actAs:
    Timestampable: ~
  columns:
    monitor_id: { type: integer(4), primary: true }
    sf_guard_group_id: { type: integer, primary: true }
  relations:
    Monitor:
      foreignAlias: GroupMonitors
    sfGuardGroup:
      foreignAlias: GroupMonitors

Actually this appears to work because doctrine can create corresponding tables.
The problem is when loading the fixures. i have this error:

  SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a c
hild row: a foreign key constraint fails (`sfmonitoring`.`alert`, CONSTRAINT `al
ert_monitor_id_monitor_id` FOREIGN KEY (`monitor_id`) REFERENCES `monitor` (`id`
))

fixures/monitors.yml

Monitor:
  monitor_one:
    id: 1
    label: task1
    url: www.task1.com
    frequency: 5
    timeout: 30
    method: GET
    parameters: a=1&b=2

  monitor_two:
    id: 2
    label: task2
    url: www.task2.com
    frequency: 5
    timeout: 20
    method: POST
    parameters: a=11&b=22

  monitor_three:
    id: 3
    label: task3
    url: www.task3.com
    frequency: 10
    timeout: 30
    method: GET
    parameters: a=111&b=211

fixures/benchmark.yml

Benchmark: 
      bench_one:
        monitor_id: 1
        server_id: 1
        connexionTime: 25
        executionTime: 25
        responseTime: 25
        responseCode: 200
        responseMessage: message de réponse

      bench_two:
        monitor_id: 2
        server_id: 2
        connexionTime: 25
        executionTime: 25
        responseTime: 25
        responseCode: 200
        responseMessage: message de réponse

      bench_three:
        monitor_id: 3
        server_id: 3
        connexionTime: 25
        executionTime: 25
        responseTime: 25
        responseCode: 200
        responseMessage: message de réponse

      bench_Four:
        monitor_id: 1
        server_id: 2
        connexionTime: 25
        executionTime: 25
        responseTime: 25
        responseCode: 200
        responseMessage: message de réponse

fixures/alerts.yml

Alert:
  alert_a:
    monitor_id: 1
    sf_guard_group_id: 1

  alert_b:
    monitor_id: 2
    sf_guard_group_id: 2Alert:
  alert_a:
    monitor_id: 1
    sf_guard_group_id: 1

  alert_b:
    monitor_id: 2
    sf_guard_group_id: 2

HELP ———> S.O.S

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:50:43+00:00Added an answer on May 24, 2026 at 10:50 am

    What does your Alert model look like? (Is that the Url_ip?)

    And it’s better to reference models by their key instead of their ID.

    Monitor:
      monitor1:
        ....
    
    Alert:
      alert_a:
        Monitor: monitor1
        Group: group1
    

    Because the error you’re getting now, means that your adding an Alert with a reference to a non-existing monitor. This could happen when the Alert is inserted before the Monitor. By referencing to the Monitor by key instead of id, symfony will insert the Monitor first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange problem with my app, sometimes, very rare in fact, when
I have a program that only requires elevation to Admin on very rare occasions
Very simply put: I have a class that consists mostly of static public members,
Very simply put, I have the following code snippet: FILE* test = fopen(C:\\core.u, w);
Very simple question, is there any cloud server enviroments avaliable these days for us
We have a bizarre and very infrequent issue where people can't log off the
I have two lists of strings that are passed into a function. They are
this is rather a very rare question and quite an unusual one.. In my
I have some string of characters (all are only alphabetic and rare newlines, no
Maybe this is a very rare (or even dumb) question, but I do need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.