Ups sorry got a mistake in there.
Should be like this
$whichKey = empty($assocData['associatedKey']) ? $model->primaryKey :
$assocData['associatedKey'];
$sql .= ' = ' . $model->escapeField($whichKey);
in dbSource.
Does anyone know if that could cause problems when i do not use $this-
>name ??
Cheers
Phil
On Jan 31, 12:18 pm, "floepi" <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> i actually had the same problem and fixed it by created my own hasOne
> function.
>
> You need to change some stuff in the dbo_source file and the
> model_php5 file.
>
> on line 873 in dbo_source you can put this code in there
>
> $associatedKey =
> trim($this->name($assocData['associatedKey']));
> $whichKey = $associatedKey =='' ?
> $model->primaryKey :
> $associatedKey;
> $sql .= ' = ' .
> $model->escapeField($whichKey);
>
> and in model_php5 on 250
>
> 'hasOne' => array('className', 'conditions', 'order',
> 'foreignKey',
> 'associatedKey', 'dependent'),
>
> when you define the hasOne association just do like this
>
> var $hasOne = array('Location' =>
> array('className' => 'Location',
> 'conditions' => '',
> 'order' => '',
> 'dependent' => true,
> 'foreignKey' => 'user_id',
> 'associatedKey' => 'user_id' // this
> one is the new key that i added in
> )
> );
>
> Works really well and lets you have hasOne connections on any table.
>
> Hope that helps.
>
> Would be nice to see that function in the official release. Tell me
> what you think.
>
> Cheers
>
> Phil
>
> On Dec 13 2006, 2:24 am, "dyssident" <[EMAIL PROTECTED]> wrote:
>
> > you know, i actually did that by accident at one point, and it did in
> > fact work. however, it broke loads of other stuff because the real
> > primary key for Profile is `id`.
>
> > if feels like i should be able to define the keys to join on at both
> > ends of the association. can it be that the only way to do one-to-one
> > joins is on the primary key?
>
> > gwoo wrote:
> > > set var $primaryKey = 'zipcode'; in Profile model
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---