如何使用PHP MongoDB中的MongoDB\Driver\Manager类使用AND逻辑运算符

如何使用PHP MongoDB中的MongoDB\Driver\Manager类使用AND逻辑运算符,php,mongodb,Php,Mongodb,如果数据库中存在用户名和密码,我想登录一个用户。我到目前为止所做的是 <?php try { $name = 'john'; $password = 12345; $manager = new MongoDB\Driver\Manager("mongodb://localhost:27017"); $filter = [ 'name' => $name ]; $query =

如果数据库中存在用户名和密码,我想登录一个用户。我到目前为止所做的是

<?php
    try {       
        $name  = 'john';
        $password = 12345;

        $manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");
        $filter = [ 'name' => $name ]; 
        $query = new MongoDB\Driver\Query($filter);     

        $res = $manager->executeQuery("DBName.Col", $query);

        $data = current($res->toArray());
        if (!empty($data)) {   

        } else {
            echo 0;
        }   
    } catch (MongoDB\Driver\Exception\Exception $e) {

        $filename = basename(__FILE__);     
        echo "The $filename script has experienced an error.\n"; 
        echo "It failed with the following exception:\n";
        echo "Exception:", $e->getMessage(), "\n";
        echo "In file:", $e->getFile(), "\n";
        echo "On line:", $e->getLine(), "\n";    
    }
?>


如果数据库中存在数据,该行将成功过滤数据
$filter=['name'=>$name]但是我怎样才能确认密码呢?如果我使用用户名获取密码,然后比较密码,这不是很奇怪吗?

$filter=['name'=>$name',password'=>$password]如果将其保留为纯文本。@AlexBlex纯文本?用于返回?用于密码。通常密码都是加密的。@AlexBlex感谢上帝保佑你。
$filter=['name'=>$name,'password'=>$password]如果将其保留为纯文本。@AlexBlex纯文本?用于返回?用于密码。密码通常是加密的。@AlexBlex感谢上帝保佑你。