Я использую Symfony 1.4, и моя схема выглядит следующим образом:
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
, когда я пытаюсь создать новую задачу, я получаю следующую ошибку:
SQLSTATE [HY000]: Общая ошибка: 1452 Невозможно добавить или обновить дочернюю строку: ограничение внешнего ключа не выполнено (ehr
. auditor_task
, CONSTRAINT auditor_task_id_expense_auditor_task_id
FOREIGN KEY (id
) ССЫЛКИ expense
(auditor_task_id
))
Одитор и задание имеют отношения многие ко многим.Таким образом, соединительный стол.у одиторов могут быть комментарии относительно задачи, поэтому я использую отношение один ко многим между аудиторской суммой и расходами.
есть идеи?
хорошо, вот след от отладки.
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"