Closed SchutzPetr closed 6 years ago
Problem muze nastat kdyz id projekta jeste neni v db. ale vidim ze u tebe je klicem i user_id i active_from. active_from nema byt klicem (u me v db neni, nevim proc je to u tebe, kdyz jsi porovnaval ty skrupty). user nedostava pokazde novou smlouvu. on muze byt rovnou zapsan na jiny projekt a uvazek bude stejny.
Prosím tedy o přiložení skriptu na vytvoření tabulky. Mám tam ten co jsi mi poslala
CREATE TABLE user_assigned_to_project
(
user_id
int(11) NOT NULL,
project_id
int(11) NOT NULL,
active_from
date NOT NULL,
active_to
date DEFAULT NULL,
obligation
double NOT NULL DEFAULT '0',
PRIMARY KEY (user_id
,project_id
,active_from
),
KEY fk_project_has_user_contract_project1_idx
(project_id
),
CONSTRAINT fk_project_has_user_contract_project1
FOREIGN KEY (project_id
) REFERENCES project
(id
) ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT fk_project_has_user_contract_user_contract1
FOREIGN KEY (user_id
) REFERENCES user_contract
(user_id
) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Děkuji
ma se jiz zavrit?
Ano, problém vyřešen
Při vytváření úvazku se zobrazí tato chyba:
array ( 'errorInfo' => array ( 0 => '23000', 1 => 1452, 2 => 'Cannot add or update a child row: a foreign key constraint fails (
attendance_new
.user_assigned_to_project
, CONSTRAINTfk_project_has_user_contract_user_contract1
FOREIGN KEY (user_id
,active_from
) REFERENCESuser_contract
(user_id
,active_from)', ), 'xdebug_message' => '( ! ) PDOException: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
attendance_new.
user_assigned_to_project, CONSTRAINT
fk_project_has_user_contract_user_contract1FOREIGN KEY (
user_id,
active_from) REFERENCES
user_contract(
user_id,
active_from) in C:\xampp\htdocs\backend\model\ProjectAssign.php on line 301 Call StackTimeMemoryFunctionLocation
10.2029398080{main}( )...\create.php:0 20.2110724632ProjectAssignService::create( )...\create.php:32 30.2256739272ProjectAssign::save( )...\ProjectAssignService.php:31 40.2256741392execute ( )...\ProjectAssign.php:301 ', )