0
I wonder if it’s possible to do this kind of relationship in the cakephp model, if it’s possible, show me how, because I’m not getting it.
Way I need to:
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 better what I need:
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 me 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 her 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
The two posted ways are identical, what’s the problem? (has an error too)
– novic
Opa, sorry @Virgilionovic, my fault, I ran out here and ended up putting twice the same code, is that in the way I need I put two references in Foreignkey and in the normal way, one should put only one, could help me in this question?
– Marcos Henzel
(I’ve already edited the question)
– Marcos Henzel
Welcome to Stackoverflow in English. I edited your question to remove the greetings, as we usually keep them as clean as possible to focus on your scheduling question. If you are interested in visiting a part of the site that is not aimed to ask questions can know the [chat]. If you have questions about the operation, rules and procedures of the site visit the [meta] :)
– user28595
Ok @diegofm, thank you so much! xD
– Marcos Henzel