开发者

A better way to use find with PHP/MongoDB?

开发者 https://www.devze.com 2023-01-18 18:23 出处:网络
I am trying to create a function that checks to see 开发者_运维技巧if a user name already exists.I am still trying to get my head wrapped around MongoDB and was wonder what is the best way to approach

I am trying to create a function that checks to see 开发者_运维技巧if a user name already exists. I am still trying to get my head wrapped around MongoDB and was wonder what is the best way to approach this? I was going to do some the following (in Code Igniter):

$filter = array ('userName' => $value);
$exists = $md->find($filter);
if ($exist) {
     return TRUE
} else {
     return FALSE
}

Is there a better way?


Looks about right, here's what I have for mine.

if ($collection->findOne(array("username" => $username)) );

return true;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号