Closed ziaratban closed 4 years ago
Thanks for contribution but this shortcut doesn't look alright:
find()
and exists()
while called exists()
.find()->where()->exists()
.Therefore decision is not to accept the pull request.
@samdark thanks.
my goals of writing this method is a simple and efficient programming. i tested this method on my employee and it had good feedback.
It's both find() and exists() while called exists().
no. it is based on-demand. when you set parameter 2 then one()
method called.
There's a pass by reference.
this is main goal. by this feature if you set then you get.
It is not significantly simpler than using find()->where()->exists().
please see this example:
$myUserForDelete = User::find()->where([...])->one();
if(!$myUserForDelete)
return 'error';
$myUserForDelete->Delete();
or
#low code
#better understanding
if(!User::Exists([...],$myUserForDelete))
return 'error';
$myUserForDelete->Delete();
Even if above is OK, that should be implemented in AR overall, not on MongoDB specifically.
only php side.
no. it is based on-demand. when you set parameter 2 then one() method called.
Yes, that's what I mean. It does two things and that is not good.
thanks for comment.
example (fetch document from database)
example (no fetch document from database)
this PR is efficient when that PR committed.