@@ -52,7 +52,6 @@ $collection = $db->selectCollection('collectionName');
52
52
53
53
// insert a record
54
54
$rid = \Jupitern\CosmosDb\QueryBuilder::instance()
55
- ->setDatabase($db)
56
55
->setCollection($collection)
57
56
->setPartitionKey('country')
58
57
->save(['id' => '1', 'name' => 'John Doe', 'age' => 22, 'country' => 'Portugal']);
@@ -61,7 +60,6 @@ echo "record inserted: $rid".PHP_EOL;
61
60
62
61
// insert a record
63
62
$rid = \Jupitern\CosmosDb\QueryBuilder::instance()
64
- ->setDatabase($db)
65
63
->setCollection($collection)
66
64
->setPartitionKey('country')
67
65
->save(['id' => '2', 'name' => 'Jane doe', 'age' => 35, 'country' => 'Portugal']);
@@ -70,7 +68,6 @@ echo "record inserted: $rid".PHP_EOL;
70
68
71
69
// update a record
72
70
$rid = \Jupitern\CosmosDb\QueryBuilder::instance()
73
- ->setDatabase($db)
74
71
->setCollection($collection)
75
72
->setPartitionKey('country')
76
73
->save(["_rid" => $rid, 'id' => '2', 'name' => 'Jane Doe Something', 'age' => 36, 'country' => 'Portugal']);
@@ -81,7 +78,6 @@ echo "get one row as array:".PHP_EOL;
81
78
82
79
// get one row as array
83
80
$res = \Jupitern\CosmosDb\QueryBuilder::instance()
84
- ->setDatabase($db)
85
81
->setCollection($collection)
86
82
->select("c.id, c.name")
87
83
->where("c.age > @age and c.country = @country")
@@ -95,7 +91,6 @@ echo "get 5 rows as array with id as array key:".PHP_EOL;
95
91
96
92
// get top 5 rows as array with id as array key
97
93
$res = \Jupitern\CosmosDb\QueryBuilder::instance()
98
- ->setDatabase($db)
99
94
->setCollection($collection)
100
95
->select("c.id, c.username")
101
96
->where("c.age > @age and c.country = @country")
@@ -110,7 +105,6 @@ echo "get rows as array of objects with collection alias and cross partition que
110
105
111
106
// get rows as array of objects with collection alias and cross partition query
112
107
$res = \Jupitern\CosmosDb\QueryBuilder::instance()
113
- ->setDatabase($db)
114
108
->setCollection($collection)
115
109
->select("TestColl.id, TestColl.name")
116
110
->from("TestColl")
@@ -124,7 +118,6 @@ echo "delete one document:".PHP_EOL;
124
118
125
119
// delete one document that match criteria (single partition)
126
120
$res = \Jupitern\CosmosDb\QueryBuilder::instance()
127
- ->setDatabase($db)
128
121
->setCollection($collection)
129
122
->setPartitionKey('country')
130
123
->where("c.age > 30 and c.country = 'Portugal'")
@@ -136,12 +129,11 @@ echo "delete all documents:".PHP_EOL;
136
129
137
130
// delete all documents that match criteria (cross partition)
138
131
$res = \Jupitern\CosmosDb\QueryBuilder::instance()
139
- ->setDatabase($db)
140
- ->setPartitionKey('country')
141
132
->setCollection($collection)
133
+ ->setPartitionKey('country')
142
134
->where("c.age > 20")
143
135
->deleteAll(true);
144
136
145
137
var_dump($res);
146
138
147
- ```
139
+ ```
0 commit comments