Hi !
I’ve need to create on-the-fly a association between the same table, processo_judicial, where another table contains reference to “both”.
My current code is:
$pjTable = TableRegistry::get('ProcessoJudicial');
$pjTable->belongsToMany('Originario',
[
'className'=>'ProcessoJudicial',
])
->setForeignKey('valor')
->setBindingKey('numero')
->setThrough('ProcessoJudicialOutroParametro')
->setConditions(['ProcessoJudicialOutroParametro.nome'=>'PROCESSO_ORIGINARIO']);
$pjs = $pjTable->find()->contain('Originario')
->where(['ProcessoJudicial.id IN'=>[134997,134998,135002,135041,135052]])
->limit(10);
debug($pjs->toArray());
The problem is that this table has values like:
In processo_judicial I have the field “numero” without “non-digits chars”:
So I need someway to CakeORM change this SQL comparison using this:
WHERE ProcessoJudicialOutroParametro.valor
in (c0, c1, c2)
to this:
WHERE (replace(replace(ProcessoJudicialOutroParametro.valor,'-',''),'.','')
in (c0, c1, c2)
How can I achive this?