У меня есть:
@method Users setMail() Sets the current record's "mail" value
@method Users setUsersGroups() Sets the current record's "UsersGroups" collection
public function save(Doctrine_Connection $conn = null) {
if($this->isNew()) {
$this->setMail('test@test.com')); // ok
$this->setUsersGroups(2); // doesn't work - error Couldn't call Doctrine_Core::set(), second argument should be an instance of Doctrine_Collection when setting one-to-many references.
}
parent::save($conn);
}
Таблица UsersGroups:
user_id
group_id
это много-много отношений
как настроить пользователей для групп?
пример схемы:
Users:
columns:
id:
type: integer(4)
autoincrement: true
primary: true
mail:
type: string(255)
password:
type: string(255)
attributes:
export: all
validate: true
Group:
tableName: group_table
columns:
id:
type: integer(4)
autoincrement: true
primary: true
name:
type: string(255)
relations:
Users:
foreignAlias: Groups
class: User
refClass: GroupUser
UsersGroups:
columns:
group_id:
type: integer(4)
primary: true
user_id:
type: integer(4)
primary: true
relations:
Group:
foreignAlias: UsersGroups
Users:
foreignAlias: UsersGroups