开发者

How to Install MongoDB and Connect to DB with PHP

I had Downloaded and installed the mongo dB And it still showing the error

Ple开发者_开发知识库ase tell me how to configure and connect to MongoDB in PHP


<?php
$client = new MongoDB\Client(
    'mongodb+srv://<username>:<password>@<cluster-address>/test?retryWrites=true&w=majority'
);
$db = $client->test;

Reference


before you connect you want to add a mongo driver for PHP, then you

[reference][1]
[video reference][2]

<?PHP
    $m = new MongoClient();
    echo "Connection to database successfully";
?>

[1]: https://www.tutorialspoint.com/mongodb/mongodb_php.htm#:~:text=%3C%3F-,php%20%2F%2F%20connect%20to%20mongodb%20%24m%20%3D%20new%20MongoClient()%3B%20echo,('%24set'%3D%3E
[2]: https://www.youtube.com/watch?v=wSIQ8n6H9os

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜