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

search for in the

MongoCollection::__construct> <MongoCollection
Last updated: Fri, 13 Nov 2009

view this page in

MongoCollection::batchInsert

(PECL mongo >=0.9.0)

MongoCollection::batchInsert複数のドキュメントをコレクションに追加する

説明

public boolean MongoCollection::batchInsert ( array $a )

パラメータ

a

配列の配列。

返り値

配列が保存できたかどうかを返します。

例1 MongoCollection::batchInsert() の例

バッチ挿入を使用すると、多くの要素を一度にデータベースに追加できます。

<?php
$batch 
= array();
for (
$i=0$i<100$i++) {
  
$batch[] = array("i" => i);
}

$m = new Mongo();
$c $m->selectCollection("foo""bar.baz");
$c->batchInsert($batch);

$cursor $c->find()->sort(array("i" => 1));
while (
$cursor->hasNext()) {
  
$obj $cursor->next();
  
var_dump($obj["i"]);
}
?>

上の例の出力は、 たとえば以下のようになります。

int(0)
int(1)
int(2)
...


add a note add a note User Contributed Notes
MongoCollection::batchInsert
There are no user contributed notes for this page.

MongoCollection::__construct> <MongoCollection
Last updated: Fri, 13 Nov 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites