Doctrine YAML not generating correctly? Or is this markup wrong?
Posted
by ropstah
on Stack Overflow
See other posts from Stack Overflow
or by ropstah
Published on 2010-04-17T21:32:29Z
Indexed on
2010/04/17
21:43 UTC
Read the original article
Hit count: 174
I'm trying to get a many-to-many relationship between Users and Settings. The models seem to be generated correctly, however the following query fails:
"User_Setting" with an alias of "us" in your query does not reference the parent component it is related to.
$q = new Doctrine_RawSql();
$q->select('{s.*}, {us.*}')
->from('User u
CROSS JOIN Setting s
LEFT JOIN User_Setting us
ON us.usr_auto_key = u.usr_auto_key
AND us.set_auto_key = s.set_auto_key')
->addComponent('s', 'Setting s INDEXBY s.set_auto_key')
->addComponent('us', 'User_Setting us')
->where(u.usr_auto_key = ?',$this->usr_auto_key);
$this->settings = $q->execute();
Does anyone spot a problem?
This is my YAML:
User:
connection: default
tableName: User
columns:
usr_auto_key:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
notnull: true
email:
type: string(100)
fixed: false
unsigned: false
primary: false
default: ''
notnull: true
autoincrement: false
password:
type: string(32)
fixed: false
unsigned: false
primary: false
default: ''
notnull: true
autoincrement: false
relations:
Setting:
class: Setting
foreignAlias: User
refClass: User_Setting
local: usr_auto_key
foreign: set_auto_key
Setting:
connection: default
tableName: Setting
columns:
set_auto_key:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
notnull: true
name:
type: string(50)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
User_Setting:
connection: default
tableName: User_Setting
columns:
usr_auto_key:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: false
notnull: true
set_auto_key:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: false
notnull: true
value:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
Setting:
foreignAlias: User_Setting
local: set_auto_key
foreign: set_auto_key
User:
foreignAlias: User_Setting
local: usr_auto_key
foreign: usr_auto_key
© Stack Overflow or respective owner