Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7172a24

Browse files
Merge 4.1 into 4.2 (#2907)
2 parents 8f7bf77 + 6c5dff2 commit 7172a24

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎docs/query-builder.txt‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ The following example shows the syntax of a query builder call:
4646
DB::collection('<collection name>')
4747
// chain methods by using the "->" object operator
4848
->get();
49+
.. tip::
50+
51+
Before using the ``DB::collection()`` method, ensure that you specify MongoDB as your application's
52+
default database connection. For instructions on setting the database connection,
53+
see the :ref:`laravel-quick-start-connect-to-mongodb` step in the Quick Start.
54+
55+
If MongoDB is not your application's default database, you can use the ``DB::connection()`` method
56+
to specify a MongoDB connection. Pass the name of the connection to the ``connection()`` method,
57+
as shown in the following code:
58+
59+
.. code-block:: php
60+
61+
$connection = DB::connection('mongodb');
4962

5063
This guide provides examples of the following types of query builder operations:
5164

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /