views:

56

answers:

0

hi, 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"