开发者

How to Install MongoDB and Connect to DB with PHP

开发者 https://www.devze.com 2022-12-07 18:44 出处:网络
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

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

精彩评论

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