I am trying to determine if an entity with certain fields exists by doing this:
However, the `else` statement never executes. How do I determine if an entity exists? The `find` method will return an object regardless of what it actually finds, so my current code doesn't work. I looked in application/Espo/ORM/Entity.php, but I couldn't find any functions that would help determine if the entity actually exists.
PHP Code:
53 # Get the latest timesheet
54 $lastTimesheet = $this->getEntityManager()->getRepository('Timesheet')->where(array(
55 'assignedUserId' => $userId
56 ))->order('createdAt', true)->limit(0, 1)->find();
57
58 if($lastTimesheet) {
59 $GLOBALS['log']->error('-E- lastTimesheet: ', $lastTimesheet->toArray());
60 } else {
61 $GLOBALS['log']->error('-E- No lastTimesheet: ', []);
62 }
Comment