1
In Cakephp associations by default it always does the relationship being the model name in the singular followed by _id, i.e., model_id.
It is possible to change this relationship key to another field of the table?
I tried to use foreignKey
but it didn’t work.
Below the two models:
<?php
class Cart_item extends AppModel
{
public $name = 'Cart_item';
}
?>
And Cart:
<?php
class Cart extends AppModel
{
public $name = 'Cart';
public $hasMany = array(
'Cart_item' => array(
'className' => 'Cart_item',
'foreignKey' => 'Cart_uid'
)
);
}
?>
foreignKey
should work. This is the way to do it. Put your code to see if there is no other mistake– Igor Martins