Download the PHP package tcb13/sequel-mongo-php without Composer
On this page you can find all versions of the php package tcb13/sequel-mongo-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package sequel-mongo-php
Sequel Mongo PHP
A lightweight, expressive, framework agnostic query builder for PHP that empowers you to run SQL-like queries on MongoDB databases. Enjoy the best of the two worlds!
Installation
Pull the package via composer.
Usage
Use MongoDB\Client
to connect to your Database:
Get one item from a collection:
Get multiple items:
select()
takes the desired fields as anarray
of strings or a variable number of parameters.
Run a complex query with multiple where
conditions, limit
and order
.
- If the operator is omitted in
where()
queries,=
will be used. Eg.->where("active", false)
; -
You can group
where
conditions by providing closures. Eg.WHERE id = 1 AND (isValid = true OR dateActivated != null)
can be written as: where()
supports the following operators=
,!=
,>
,>=
,<
,<=
;-
SQL's
WHERE IN()
is also available: -
WHERE NOT IN()
is also available viawhereNotIn()
andorWhereNotIn()
respectively; -
Examples of other useful String queries:
- For more complex String queries you may also use regex:
Count Documents
You may count the number of documents/records that match a query with the count()
method:
Note that you may not call find()
or findAll()
in combination with this method.
Insert a document:
- You may also insert multiple documents at once:
Delete a Document:
Update a Document:
- You may update only a few fields or an entire document - like like an SQL
update
statement.
Join Collections:
join($collectionToJoin, $localField, $operatorOrForeignField, $foreignField)
Special Functions:
Max(string $property, ?string $alias = null) - get the maximum value in a set of values:
Min(string $property, ?string $alias = null) - get the minimum value in a set of values:
Increment(string $propertyName, int $incrementBy = 1) - increment or decrement a document property by a value:
ArrayContains(string $arrayProperty, $needles) - check if an array in a document contains a value (or at least one value if an array is passed):
ArrayLength(string $arrayProperty, ?string $alias = null) - get the length of an array:
ArrayPush(string $arrayProperty, mixed $value) - add an element to an array. Example: document with a tokens
property that is an array:
ArrayPull(string $arrayProperty, mixed $value) - remove an element from an array. Example: document with a tokens
property that is an array:
Debug Queries:
It is possible possible to debug the query pipeline built by the Query Builder for each query.
For more examples check out the examples
directory.
All versions of sequel-mongo-php with dependencies
ext-json Version *
ext-curl Version *
ext-mongodb Version *
mongodb/mongodb Version *