-
Notifications
You must be signed in to change notification settings - Fork 0
/
operateurs.php
68 lines (52 loc) · 1.64 KB
/
operateurs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
//Fichier index
$connection=new MongoClient('127.0.0.1:27017');
$db=$connection->selectDB('test');
$collection=$db->samples;
$users=array('nom'=>'Wabi','prenom'=>'Spider',
'addressse'=>'Yop City','city'=>'Babi','state'=>'Babi','zip'=>'225');
//$collection->insert($users,array('w' => true));
$slice=$collection->find(array(),array('prenom'=>array('$slice'=>array(4,10))));
foreach ($slice as $document)
{
print_r($document);
}
echo "dsc ksjdcsc <br/>";
$set = $collection->find(array('age' =>array('$in' =>array(43,30,20))));
var_dump($set);
foreach ($set as $document)
{
print_r($document);
}
$all = $collection->find(array('age' =>array('$all' =>array(25,23))));
var_dump($all);
foreach ($all as $document)
{
print_r($document);
}
$resultat_lt=$collection->find(array('age'=>array('$lt'=>25)));
$resultat_gt=$collection->find(array('age'=>array('$gt'=>25)));
/*foreach ($resultat_gt as $document)
{
print_r($document);
}
for($i=0;$i<count($resultat_lt);$i++)
{
echo count($resultat_lt);
}
foreach ($resultat_lt as $document)
{
echo ($document["nom"]);
}
*/
/*
var_dump($collection->w);
$pk = $users['_id'];
var_dump($pk);*/
/*$pp = $collection->findOne(array('nom' => 'Wabi','prenom' => 'Spider'),array('addressse','zip'));
var_dump($pp);*/
//$collection->update(array('_id'=>new MongoId('589040625b3fca581d00002b')),array('$set'=>array('situation'=>'marié','fonction'=>'Développpeur')));
/*$collection->update(array('_id'=>new MongoId('58917d3e5b3fcac410000032')),array('nom'=>'Peter','prenom'=>'Parker'),
array('$set'=>array('adresse'=>'wall crawling'))
);*/
//$collection->remove(array('_id'=>new MongoId('58917ce85b3fcac410000031')));