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 4577446
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:20:49+00:00 2026-05-21T20:20:49+00:00

i’m using symfony 1.4, and my schema is as follows: Auditor: columns: id: type:

  • 0

i’m using symfony 1.4, and my schema is as follows:

Auditor:
  columns:
    id:
      type: integer
      autoincrement: true
      primary: true
    username:
      type: string(255)
    password:
      type: string(255)
    fullname:
      type: string(255)
    is_auditor:
      type: integer
    is_manager:
      type: integer
    is_director:
      type: integer

Task:
  columns:
    id:
      type: integer
      autoincrement: true
      primary: true
    client:
      type: string(255)
    start_date:
      type: date
    end_date:
      type: date
    assigned_by:
      type: string(255)
    comments:
      type: string
    status:
      type: integer
  relations:
    Auditors:
      foreignAlias: Tasks
      class: Auditor
      refClass: AuditorTask

AuditorTask:
  columns:
    id:
      type: integer
      autoincrement: true
      primary: true
    auditor_id:
      type: integer
      primary: true
    task_id:
      type: integer
      primary: true
  relations:
    Auditor:
      foreignAlias: AuditorTasks
    Task:
      foreignAlias: AuditorTasks

Expense:
  columns:
    id:
      type: integer
      autoincrement: true
      primary: true
    auditor_task_id:
      type: integer
    date:
      type: date
    hours_spent:
      type: integer
    transport_cost:
      type: float
    remarks:
      type: string
  relations:
    AuditorTask:
      foreignAlias: Expenses

when i try to create a new Task, i get the following error:

SQLSTATE[HY000]: General error: 1452 Cannot add or update a child row: a foreign key constraint fails (ehr.auditor_task, CONSTRAINT auditor_task_id_expense_auditor_task_id FOREIGN KEY (id) REFERENCES expense (auditor_task_id))

auditor and task has a many to many relationship. thus the junction table. the auditors can have comments regarding the task, thus i’m using the one to many relationship between auditortask adn expense.

any ideas?

ok here is a trace from the debug.

1   Info sfPatternRouting   Match route "default" (/:module/:action/*) for /task/create with parameters array ( 'module' => 'task', 'action' => 'create',)
2   Info sfFilterChain  Executing filter "sfRenderingFilter"
3   Info sfFilterChain  Executing filter "sfExecutionFilter"
4   Info taskActions    Call "taskActions->executeCreate()"
5   Info Doctrine_Connection_Mysql  exec : SET NAMES 'UTF8' - ()
6   Info Doctrine_Connection_Statement  execute : SELECT COUNT(*) AS num_results FROM auditor a WHERE a.id IN (?) - (1)
7   Info Doctrine_Connection_Statement  execute : SELECT a.id AS a__id, a.username AS a__username, a.password AS a__password, a.fullname AS a__fullname, a.is_auditor AS a__is_auditor, a.is_manager AS a__is_manager, a.is_director AS a__is_director FROM auditor a WHERE (a.id IN (?)) - (1)
8   Info Doctrine_Connection_Statement  execute : INSERT INTO task (client, start_date, end_date, assigned_by, comments, status) VALUES (?, ?, ?, ?, ?, ?) - (Falcon Limited, 2005-01-02, 2005-02-02, mr manager one, asap., 0)
9   Info Doctrine_Connection_Statement  execute : INSERT INTO auditor_task (auditor_id, task_id) VALUES (?, ?) - (1, 1)
10  Error Doctrine_Connection_Mysql_Exception   SQLSTATE[HY000]: General error: 1452 Cannot add or update a child row: a foreign key constraint fails (`ehr`.`auditor_task`, CONSTRAINT `auditor_task_id_expense_auditor_task_id` FOREIGN KEY (`id`) REFERENCES `expense` (`auditor_task_id`))
11  Info sfWebResponse  Send status "HTTP/1.1 500 Internal Server Error"
12  Info sfWebResponse  Send header "Content-Type: text/html; charset=utf-8" 
  • 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-21T20:20:49+00:00Added an answer on May 21, 2026 at 8:20 pm

    It seems like it is the primary key you’ve defined on AuditorTask. You’ve set ‘id’, ‘auditor_id’ and ‘task_id’ to be PK. Remove the PK-statement from ‘auditor_id’ and ‘task_id’ and the following works:

    insert into auditor(username)values('user');
    insert into task(client)values('The client');
    insert into auditor_task(auditor_id, task_id)values(1,1);
    insert into expense(auditor_task_id, hours_spent)values(1,2);
    

    For reference, this is how AuditorTask looks like after the modification:

    AuditorTask:
      columns:
        id:
          type: integer
          autoincrement: true
          primary: true
        auditor_id:
          type: integer
        task_id:
          type: integer
      relations:
        Auditor:
          foreignAlias: AuditorTasks
        Task:
          foreignAlias: AuditorTasks
    

    I see you are using MySQL. Did MySQL even let you create the tables the way they were defined? Postgres (which I primarily use) saw that something was fishy and didn
    t even accept table creation the way it was defined. 😉

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I've got a string that has curly quotes in it. I'd like to replace

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.