downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

MongoDB::__construct> <MongoDB
[edit] Last updated: Fri, 18 Sep 2009

view this page in

MongoDB::command

(PECL mongo >=0.9.2)

MongoDB::commandExecute a database command

Описание

public array MongoDB::command ( array $data )

Параметри

data

The query to send.

Връщани стойности

Returns database response.



MongoDB::__construct> <MongoDB
[edit] Last updated: Fri, 18 Sep 2009
 
add a note add a note User Contributed Notes MongoDB::command
Anonymous 08-Jun-2011 04:18
> 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);
?>
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);
?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites