Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.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条令-YAML语法帮助。多对多关系的默认值?_Php_Doctrine_Yaml_Relationships - Fatal编程技术网

PHP条令-YAML语法帮助。多对多关系的默认值?

PHP条令-YAML语法帮助。多对多关系的默认值?,php,doctrine,yaml,relationships,Php,Doctrine,Yaml,Relationships,我有以下YAML模式用于组织条令中的用户: Person: tableName: people columns: id: type: integer primary: true autoincrement: true firstname: type: string notnull: true lastname: type: string notnull: true User:

我有以下YAML模式用于组织条令中的用户:

Person:
  tableName: people
  columns:
    id:
      type: integer
      primary: true
      autoincrement: true 
    firstname:
      type: string
      notnull: true
      lastname:
      type: string
      notnull: true
User:
  inheritance:
  extends: Person
    type: column_aggregation
    keyField: type
    keyValue: 1
Userdetails:
  columns:
    person_id:
      type: integer
      primary: true
    password:
      type: string
      notnull: true
  relations:
    User:
      foreignType: one
      local: person_id
      onDelete: CASCADE
      onUpdate: CASCADE
Group:
  tableName: groups
  columns:
    id:
      type: integer
      primary: true
      autoincrement: true
    name:
      type: string
      notnull: true
UserGroup:
  columns:
    group_id:
      type: integer
      primary: true
      person_id:
      type: integer
      primary: true
  relations:
    User:
      foreignType: many
      local: person_id
    Group:
      foreignType: many 
基本上,任何用户都将属于一个或多个组。
默认情况下,有没有办法向特定组添加新用户

谢谢你的建议


谢谢

我必须管理,我不再使用最新的条令版本,但是由于它的记录需要一个默认构造函数,我认为它应该足以从用户构造函数中的数据库加载默认组

class User extends Doctrine_Record
{
    public __construct()
    {
        parent::__construct();
        $this->groups[] = Doctrine::getTable('Group')->findByName('DefaultGroup');
    }
}

$blauser = new User();
$blauser->save(); // Will save the user with the default group

根据您的体系结构,您可能需要考虑将该初始化也放入控制器中。