tenants
Well-known member
I just hit a little snag, I think it's useful mentioning (even if it's self reference)
If I have stuff in the database, this will work fine as a query:
But this returns null:
It seems findOne doesnt work with gt operators (Or at least not the way I am using the operator)
In the core code, I found this:
I'm not really sure why, but the finder->fetchOne works as a work around
If I have stuff in the database, this will work fine as a query:
Code:
$expiredTime = \XF::$time - (7 * 86400);
$projectInvite = \XF::app()->finder('Tenants\ToolsAdmin:ProjectInviteEntity')
->where('created_date', '>', $expiredTime) // 7 day expiration
->fetchOne(); // something returned
But this returns null:
Code:
$expiredTime = \XF::$time - (7 * 86400);
$projectInvite = $this->em()->findOne('Tenants\ToolsAdmin:ProjectInviteEntity', [
'created_date' => ['>', $expiredTime],
]); // null returned, ehhhh?
It seems findOne doesnt work with gt operators (Or at least not the way I am using the operator)
In the core code, I found this:
Code:
public function findOne($shortName, array $where, $with = null){
$finder = $this->getFinder($shortName);
$finder->where($where); // this is thus: ['created_date' => ['>', $expiredTime]], which is not the same as : 'created_date', '>', $expiredTime
if ($with)
{
$finder->with($with);
}
return $finder->fetchOne();
}
I'm not really sure why, but the finder->fetchOne works as a work around