I've just started getting into Symfony / Doctrine, but I'm running
into an issue creating the join. I have a pre-existing database that
I'm trying to create a new site around, so I have used "doctrine:build-
schema" to create the model, forms, etc off of MySQL. It's using
INNODB and here's the two tables sql:
CREATE TABLE `Address` (
`AddressID` int(10) unsigned NOT NULL auto_increment,
`StreetNumber` int(10) unsigned NOT NULL,
`StreetName` varchar(100) NOT NULL,
`StreetSuffix` varchar(40) NOT NULL,
PRIMARY KEY (`AddressID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `House` (
`HouseID` int(10) unsigned NOT NULL auto_increment,
`AddressID` int(10) unsigned NOT NULL,
`Taxes` decimal(6,2) default NULL,
`Active` enum('y','n') NOT NULL default 'y',
PRIMARY KEY (`HouseID`),
KEY `AddressID` (`AddressID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `House` ADD CONSTRAINT `House_ibfk_1` FOREIGN KEY
(`AddressID`) REFERENCES `Address` (`AddressID`) ON DELETE CASCADE ON
UPDATE CASCADE;
This produced the following model (config/doctrine/schema.yml):
Address:
tableName: Address
columns:
addressid:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: true
streetnumber:
type: integer(4)
fixed: false
unsigned: true
primary: false
notnull: true
autoincrement: false
streetname:
type: string(100)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
streetsuffix:
type: string(40)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
House:
local: addressid
foreign: addressid
type: many
House:
tableName: House
columns:
houseid:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: true
addressid:
type: integer(4)
fixed: false
unsigned: true
primary: false
notnull: true
autoincrement: false
taxes:
type: decimal(6)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
scale: false
active:
type: enum(1)
fixed: false
unsigned: false
values: ['y', 'n']
primary: false
default: 'y'
notnull: true
autoincrement: false
relations:
Address:
local: addressid
foreign: addressid
type: one
So when I try to do:
public function executeIndex(sfWebRequest $request)
{
$q = Doctrine_Query::create()
->from('House h')
->leftJoin('h.addressid a')
->where('h.active = ?', 'y');
$this->house_list = $q->execute();
}
I get this error:
Unknown relation alias addressid
I'm still learning doctrine for the first time, so I have a feeling it
might be in the model where I will need to fix the schema.yml
relations and the generate the model over again, but I'm not sure who
it's supposed to look. All examples I've seen have the column names
with two different names where both my tables have the same name for
the same value, "addressid". I'm also not sure when I imported the
schema in, if it was smart enough to take into the acount of the
innodb foreign keys. Any help would be greatly appreciated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---