Escolar Documentos
Profissional Documentos
Cultura Documentos
C:\mongodb\server\3.x\bin>
mongod -dbpath
C:\mongodb\server\3.x\data
/Applications/mongo-x/bin>
./mongod -dbpath
/Applications/mongo-x/data
3 MongoDB
carga de dados normalizada
use databaseName
db.customers.createIndex({ "tags":
1 });
4 PHP
baixar driver mongodb
$ git clone
https://github.com/mongodb/mongo
-php-driver.git
$ cd mongo-php-driver
$ git submodule sync && git
submodule update init
$ phpize
$ ./configure
$ make
$ sudo make install
4 PHP
php.ini
extension=mongodb.so
4 PHP
conexo
$mongo = new
MongoDB\Driver\Manager( mongo
db://usuario:senha@servidor.mlab.
com:23400/nomeDoBanco);
4 PHP
formulrio
<html>
<head></head>
<body>
<form method=GET
action=pesquisa.php>
<p><label
for=txtPesquisa>Pesquisa: <input
type=text id=txtPesquisa
name=txtPesquisa /></p>
<input type=submit
value=Pesquisar />
</form>
</body>
</html>
4 PHP
pesquisa
$mongo = new
MongoDB\Driver\Manager('mongod
b://localhost/luiztools');
$filter = ['tags' => ['$all' =>
$search ] ];
$query = new
MongoDB\Driver\Query($filter,
['sort' => [ 'nome' => 1], 'limit' =>
5]);
$rows = $mongo-
>executeQuery("luiztools.customer
s", $query);