I would like to know if it is possible to do this kind of relationship in Cakephp's Model, if it is possible, show me how, because I can not.
Way I need it:
public $belongsTo = array(
Status => array(
'className' => 'Status',
'foreignKey' => 'status_id_origem', 'status_id_destino',
'dependent' => false,
),
);
Normal way:
public $belongsTo = array(
Status => array(
'className' => 'Status',
'foreignKey' => 'status_id_origem',
'dependent' => false,
),
);
Specifying what I need best:
I run the following query:
SELECT Historico.*, Status.descricao
FROM historicos as Historico
LEFT JOIN statuses as Status
ON (Status.id = Historico.status_id_origem)
Soon this query returns the following:
id integer|status_id_origem integer|status_id_destino integer|descricao
----------|------------------------|-------------------------|---------
44 | 1 | 2 | Aguardando embarque
43 | 1 | 2 | Aguardando embarque
But what I really need it to get back to me is this:
id integer|status_id_origem integer|status_id_destino integer|descricaoIdOrigem varchar|descricaoIdDestino varchar
----------|------------------------|-------------------------|-------------------------|------------------------
44 | 1 | 2 | Aguardando embarque | Embarcado
43 | 1 | 2 | Aguardando embarque | Embarcado