所以,我有一个名为'会员'的集合,并且我有我的每个'成员'的用户名和密码。 我需要知道的是我怎么检查,看看两者是否匹配,即用户名+密码=成功简单的PHP mongoDB用户名和密码检查网站
这是我曾尝试并正确进行搜索,只是它没有返回错误,如果没有用户
public function userlogin($data)
{
$this->data = $data;
$collection = $this->db->members;
// find everything in the collection
$cursor = $collection->find(array("username"=>$this->data['username'], "password"=>$this->data['password']));
$test = array();
// iterate through the results
while($cursor->hasNext()) {
$test[] = ($cursor->getNext());
}
//Print Results
if($test == NULL)
{
print "Sorry we are not able to find you";
die;
}
//print json_encode($test);
}
感谢芽,我怎么什么限制返回得到,我只想有_id数量和@RussellHarrower你可以使用'findOne'或'limit'姓氏和名字 – RussellHarrower 2012-03-22 21:49:56
。检查更新。 – Ben 2012-03-22 22:01:30