Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony 1.4,原则:多个连接到一个表_Php_Symfony 1.4 - Fatal编程技术网

Php Symfony 1.4,原则:多个连接到一个表

Php Symfony 1.4,原则:多个连接到一个表,php,symfony-1.4,Php,Symfony 1.4,该计划: User: options: collate: utf8_unicode_ci charset: utf8 tableName: users columns: ID: type: integer(4) primary: true autoincrement: true USERNAME: type: string(255) notnull: true Task: options

该计划:

User:
  options:
    collate: utf8_unicode_ci
    charset: utf8
  tableName: users
  columns:
    ID:
      type: integer(4)
      primary: true
      autoincrement: true
    USERNAME:
      type: string(255)
      notnull: true

Task:
  options:
    collate: utf8_unicode_ci
    charset: utf8
  tableName: tasks
  columns:
    ID:
      type: integer(4)
      primary: true
      autoincrement: true
    CREATED_ID:
      type: integer(4)
      notnull: true
    OWNER_ID:
      type: integer(4)
      notnull: true
    DESCRIPTION:
      type: text
      notnull: true
  relations:
    User:
      onDelete: CASCADE
      local: CREATED_ID
      foreign: ID
    User:
      onDelete: CASCADE
      local: OWNER_ID
      foreign: ID
如您所见,Task.OWNER_ID和Task.CREATED_ID指向User.ID-但在实际SQL表中,只有OWNER_ID显示为外键:

CREATE TABLE  `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE  `tasks` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `created_id` int(11) NOT NULL,
  `owner_id` int(11) NOT NULL,
  `description` text COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  KEY `owner_id_idx` (`owner_id`),
  CONSTRAINT `tasks_owner_id_users_id` FOREIGN KEY (`owner_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Symfony不会删除任何错误。不允许我定义更多的表联接吗?

您的方案是。。。不完全正确。试试这个

  relations:
    UserCreator:
      class: User
      onDelete: CASCADE
      local: CREATED_ID
      foreign: ID
      foreignAlias: Tasks
    UserOwner:
      class: User
      onDelete: CASCADE
      local: OWNER_ID
      foreign: ID
      foreignAlias: Tasks

加入的查询在哪里?在哪里,Symfony建立了db Symfony原则:build--all--no confirmation