> Need to know the database version? There's a command for that.
We didn't find it - ended up using either;
<?php
$m = new Mongo();
$adminDB = $m->admin; //require admin priviledge
$mongodb_info = $adminDB->command(array('buildinfo'=>true));
$mongodb_version = $mongodb_info['version'];
print_r($mongodb_info);
?>
or
<?php
$v = `mongo --version`;
print_r($v);
?>
MongoDB::command
(PECL mongo >=0.9.2)
MongoDB::command — Execute a database command
Описание
public array MongoDB::command
( array $data
)
Параметри
- data
-
The query to send.
Връщани стойности
Returns database response.
Anonymous
08-Jun-2011 04:18
roman dot drapeko at gmail dot com
16-Apr-2011 02:07
I tried to write MapReduce. Unfortunately, out => array('replace' => 'collName') did not work for me. Instead, the below code works
<?php
$mongo->command(array(
'mapreduce' => 'events',
'map' => $map,
'reduce' => $reduce,
'out' => 'mapReduceEventStats'
));
?>
Min He
21-Jul-2010 04:31
rename a collection:
<?php
$m = new Mongo();
$adminDB = $m->admin; //require admin priviledge
//rename collection 'colA' in db 'yourdbA' to collection 'colB' in another db 'yourdbB'
$res = $adminDB->command(array(
"renameCollection" => "yourdbA.colA",
"to" => "yourdbB.colB"
));
var_dump($res);
?>
