File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -38,15 +38,20 @@ testability.
38
38
39
39
The {+odm-short+} provides the ``DB`` method ``table()`` to access a collection.
40
40
Chain methods to specify commands and any constraints. Then, chain
41
- the ``get()`` method at the end to run the methods and retrieve the results.
41
+ the ``get()`` method at the end to run the methods and retrieve the
42
+ results. To retrieve only the first matching result, chain the
43
+ ``first()`` method instead of the ``get()`` method. Starting in
44
+ {+odm-long+} v5.0, the query builder returns results as ``stdClass`` objects.
45
+
42
46
The following example shows the syntax of a query builder call:
43
47
44
48
.. code-block:: php
45
49
46
50
DB::table('<collection name>')
47
51
// chain methods by using the "->" object operator
48
52
->get();
49
- .. tip::
53
+
54
+ .. tip:: Set Database Connection
50
55
51
56
Before using the ``DB::table()`` method, ensure that you specify MongoDB as your application's
52
57
default database connection. For instructions on setting the database connection,
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ Upgrade Library Version
14
14
.. contents:: On this page
15
15
:local:
16
16
:backlinks: none
17
- :depth: 1
17
+ :depth: 2
18
18
:class: singlecol
19
19
20
20
Overview
@@ -71,6 +71,26 @@ Version 5.x Breaking Changes
71
71
72
72
This library version introduces the following breaking changes:
73
73
74
+ - The query builder returns results as as ``stdClass`` objects instead
75
+ of as arrays. This change requires that you change array access to
76
+ property access when interacting with query results.
77
+
78
+ The following code shows how to retrieve a query result and access a
79
+ property from the result object in older versions compared to v5.0:
80
+
81
+ .. code-block:: php
82
+ :emphasize-lines: 8-9
83
+
84
+ $document = DB::table('accounts')
85
+ ->where('name', 'Anita Charles')
86
+ ->first();
87
+
88
+ // older versions
89
+ $document['balance'];
90
+
91
+ // v5.0
92
+ $document->balance;
93
+
74
94
- Removes support for the following classes:
75
95
76
96
- ``MongoDB\Laravel\Auth\DatabaseTokenRepository``. Instead, use the default
You can’t perform that action at this time.
0 commit comments