E
E
earth42014-04-04 02:51:26
PHP
earth4, 2014-04-04 02:51:26

How to call a javascript mongodb function from php?

in php I call mongodb javascript function start()

$username="root"; 
$password="root";
$mongo_uri="mongodb://".$username.":".$password."@localhost";
$connection = new MongoClient( $mongo_uri );
$db = $connection->test;

$response = $db->execute("start()");

echo "<pre>"; print_r($response); echo "</pre>";

as a result I get
Array
(
    [ok] => 0
    [errmsg] => unauthorized
)

$username + $password + $mongo_uri are correct, and $db gives "ok" connection, there is a start() function in the database - everything is checked,
but I get an unauthorized error on $response = $db->execute("start()" );
how to call mongodb start() function from php?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Serj-One, 2015-08-19
@klonor

I will partially support the answer of Pavel Kizernis , but I will only advise a newer version - www.owlcarousel.owlgraphic.com It is much more functional.

P
Pavel Kizernis, 2015-08-19
@pashakiz

I recommend
owlgraphic.com/owlcarousel

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question