Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 36647 программистов и 1762 робота. Сейчас ищут 1338 программистов ...
Приступая к работе

Setting Criteria for a Query

Вернуться к: Tutorial

We can create a query to pass to the MongoCollection::find() method to get a subset of the documents in our collection. For example, if we wanted to find the document for which the value of the "i" field is 71, we would do the following:

<?php
$connection 
= new MongoClient();
$collection $connection->database->collectionName;

$query = array( 'i' => 71 );
$cursor $collection->find$query );

while ( 
$cursor->hasNext() )
{
    
var_dump$cursor->getNext() );
}
?>

Результат выполнения данного примера:

array(2) {
  ["_id"]=>
  object(MongoId)#6 (0) {
  }
  ["i"]=>
  int(71)
  ["_ns"]=>
  "testCollection"
}


Вернуться к: Tutorial

© 2025 «PHP.RU — Сообщество PHP-Программистов»
Главная | Форум | Реклама на сайте | Контакты VIP Сувениры
Разработка компании ODware