Hello all,
Im having a problem with a one-to-one association.
Table `profiles` has a field `zipcode` containing the users zipcode.
Table `zipcodes` has a primary key `zipcode` containting a zipcode. Im
trying to do a one-to-one association on the zipcode fields, but cake
is insisting on joining `Zipcode.zipcode` to `Profile.id`.
<code>
<?php
class Profile extends AppModel
{
var $name = 'Profile';
var $hasOne = array(
'Zipcode' => array(
'foreignKey' => 'zipcode'
)
);
}
?>
<?php
class Zipcode extends AppModel
{
var $name = 'Zipcode';
var $primaryKey = 'zipcode';
var $belongsTo = array('Profile' =>
array(
'foreignKey' => 'zipcode'
)
);
}
?>
</code>
SQL debug output is
<code>
SELECT *, DATE_FORMAT( FROM_DAYS( TO_DAYS( NOW() ) - TO_DAYS(
Profile.birthdate ) ), '%Y') + 0 AS age, MATCH (keywords) AGAINST
("stuff") AS rank, GeoDistKM(47.4323, -121.803, Zipcode.latitude,
Zipcode.longitude) as distancekm FROM `profiles` AS `Profile` LEFT
JOIN `zipcodes` AS `Zipcode` ON `Zipcode`.`zipcode` = `Profile`.`id`
WHERE ( GeoDistKM(47.4323, -121.803, Zipcode.latitude,
Zipcode.longitude) < 100)
</code>
Notice the "ON `Zipcode`.`zipcode` = `Profile`.`id`". Any clues on how
to make this read "Zipcode.zipcode = Profile.zipcode"?
Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Cake PHP" 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/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---