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 the conditions
array are interpreted as 'AND' conditions.
So your query would look like:-
$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,
'Transaction.name !=' => 'Facturation'
]
]
);
You only need to index by and
if you have duplicate condition array keys; this is not the case in your example as you have Transaction.id
and Transaction.name !=
. Regardless, the and
index would need to be an index inside the conditions
array, not a sibling.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With