You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Drivers/PHP/Tutorial/README.md
-21Lines changed: 0 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,4 @@
1
1
# ArangoDB-PHP - Tutorial
2
-
<aname="setting_up_connection_options"></a>
3
2
## Setting up the connection options
4
3
5
4
In order to use ArangoDB, you need to specify the connection options. We do so by creating a PHP array $connectionOptions. Put this code into a file named test.php in your current directory:
@@ -76,7 +75,6 @@ When updating a document that was previously/concurrently updated by another use
76
75
* fail with a conflict error: if you prefer that, set OPTION_UPDATE_POLICY to conflict
77
76
78
77
79
-
<aname="setting_up_failover"></a>
80
78
## Setting up active failover
81
79
82
80
By default the PHP client will connect to a single endpoint only,
@@ -135,10 +133,8 @@ $connectionOptions = [
135
133
```
136
134
137
135
138
-
<aname="creating_collection"></a>
139
136
## Creating a collection
140
137
*This is just to show how a collection is created.*
141
-
<br>
142
138
*For these examples it is not needed to create a collection prior to inserting a document, as we set ArangoConnectionOptions::OPTION_CREATE to true.*
143
139
144
140
So, after we get the settings, we can start with creating a collection. We will create a collection named "users".
@@ -168,8 +164,6 @@ The below code will first set up the collection locally in a variable name $user
168
164
var_dump($result);
169
165
170
166
```
171
-
172
-
<aname="creating_document"></a>
173
167
## Creating a document
174
168
175
169
After we created the collection, we can start with creating an initial document. We will create a user document in a collection named "users". This collection does not need to exist yet. The first document we'll insert in this collection will create the collection on the fly. This is because we have set OPTION_CREATE to true in $connectionOptions.
@@ -206,7 +200,6 @@ Document properties can be set by using the set() method, or by directly manipul
206
200
207
201
As you can see, sending a document to the server is achieved by calling the save() method on the client library's *DocumentHandler* class. It needs the collection name ("users" in this case") plus the document object to be saved. save() will return the document id as created by the server. The id is a numeric value that might or might not fit in a PHP integer.
208
202
209
-
<aname="adding_exception_handling"></a>
210
203
## Adding exception handling
211
204
212
205
@@ -245,7 +238,6 @@ try {
245
238
}
246
239
```
247
240
248
-
<aname="retrieving_document"></a>
249
241
## Retrieving a document
250
242
251
243
To retrieve a document from the server, the get() method of the *DocumentHandler* class can be used. It needs the collection name plus a document id. There is also the getById() method which is an alias for get().
@@ -297,7 +289,6 @@ Whenever the document id is yet unknown, but you want to fetch a document from t
297
289
This will return all documents from the specified collection (here: "users") with the properties provided in the example (here: that have an attribute "name" with a value of "John"). The result is a cursor which can be iterated sequentially or completely. We have chosen to get the complete result set above by calling the cursor's getAll() method.
298
290
Note that CollectionHandler->byExample() might return multiple documents if the example is ambigious.
299
291
300
-
<aname="updating_document"></a>
301
292
## Updating a document
302
293
303
294
@@ -374,7 +365,6 @@ The document that is replaced using the previous example must have been fetched
374
365
375
366
```
376
367
377
-
<aname="deleting_document"></a>
378
368
## Deleting a document
379
369
380
370
To remove an existing document on the server, the remove() method of the *DocumentHandler* class will do. remove() just needs the document to be removed as a parameter:
@@ -400,7 +390,6 @@ Note that the document must have been fetched from the server before. If you hav
400
390
```
401
391
402
392
403
-
<aname="running_aql"></a>
404
393
## Running an AQL query
405
394
406
395
@@ -472,7 +461,6 @@ the `_flat` attribute. This allows processing the results of arbitrary AQL queri
472
461
```
473
462
474
463
475
-
<aname="exporting_data"></a>
476
464
## Exporting data
477
465
478
466
@@ -514,8 +502,6 @@ over all documents in a collection.
See file examples/customDocumentClass.php for more details.
592
576
593
-
<aname="logging_exceptions"></a>
594
577
## Logging exceptions
595
578
596
579
@@ -616,7 +599,6 @@ use ArangoDBClient\Exception as ArangoException;
616
599
ArangoException::disableLogging();
617
600
```
618
601
619
-
<aname="alltogether"></a>
620
602
## Putting it all together
621
603
622
604
Here's the full code that combines all the pieces outlined above:
@@ -905,11 +887,8 @@ try {
905
887
906
888
```
907
889
908
-
<br>
909
-
910
890
911
891
912
-
<aname="more_info"></a>
913
892
# More information
914
893
915
894
* More example code, containing some code to create, delete and rename collections, is provided in the **examples** subdirectory that is provided with the library.
0 commit comments