can you see the error guys ? my AND conditions is ignored! I'm getting so frustrated with those arrays..
$transaction_query = $this->Transaction->find('all',
[
'limit' => $countList,
'fields' => ['Transaction.client_id','Transaction.name','Transaction.created','Transaction.message_id','Transaction.credit'],
'conditions' => ['Transaction.id' => $client_id],
'AND' => ['Transaction.name !=' => 'Facturation']
]);
Your conditions need to be
['Transaction.id' => $client_id, 'Transaction.name !=' => 'Facturation']
. Multiple conditions of theconditions
array are interpreted as 'AND' conditions.So your query would look like:-
You only need to index by
and
if you have duplicate condition array keys; this is not the case in your example as you haveTransaction.id
andTransaction.name !=
. Regardless, theand
index would need to be an index inside theconditions
array, not a sibling.