-
Notifications
You must be signed in to change notification settings - Fork 48
setLimit(1) not working #1010
Copy link
Copy link
Closed
Labels
Description
Steps to reproduce:
- Select any model and add some conditions which result in multiple records. Optionally also setOrder.
- Apply setLimit(1) to restrict to one record only
- Then tryLoadOne()
I get this error: Atk4\Data\Exception: Ambiguous conditions, more than one record can be loaded
Code snippet:
$customermodel = new \Atk4\Data\Model\Customer($db);
$customermodel->addCondition(\Atk4\Data\Model\Scope::CreateOr(['phone', 'LIKE', '%'.$number.'%'], ['mobile', 'LIKE', '%'.$number.'%']));
$customermodel->setOrder(['id']);
$customermodel->setLimit(1);
$entity = $customermodel->tryLoadOne();
What should be expected:
If there was minimum one entity matching the conditions, $entity should contain that (first) one, otherwise $entity == null.
Reactions are currently unavailable