repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
yiisoft/yii2-mongodb
src/Collection.php
Collection.findAndModify
public function findAndModify($condition, $update, $options = []) { return $this->database->createCommand()->findAndModify($this->name, $condition, $update, $options); }
php
public function findAndModify($condition, $update, $options = []) { return $this->database->createCommand()->findAndModify($this->name, $condition, $update, $options); }
[ "public", "function", "findAndModify", "(", "$", "condition", ",", "$", "update", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "database", "->", "createCommand", "(", ")", "->", "findAndModify", "(", "$", "this", "->", "na...
Updates a document and returns it. @param array $condition query condition @param array $update update criteria @param array $options list of options in format: optionName => optionValue. @return array|null the original document, or the modified document when $options['new'] is set. @throws Exception on failure.
[ "Updates", "a", "document", "and", "returns", "it", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Collection.php#L252-L255
yiisoft/yii2-mongodb
src/Collection.php
Collection.insert
public function insert($data, $options = []) { return $this->database->createCommand()->insert($this->name, $data, $options); }
php
public function insert($data, $options = []) { return $this->database->createCommand()->insert($this->name, $data, $options); }
[ "public", "function", "insert", "(", "$", "data", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "database", "->", "createCommand", "(", ")", "->", "insert", "(", "$", "this", "->", "name", ",", "$", "data", ",", "$", ...
Inserts new data into collection. @param array|object $data data to be inserted. @param array $options list of options in format: optionName => optionValue. @return \MongoDB\BSON\ObjectID new record ID instance. @throws Exception on failure.
[ "Inserts", "new", "data", "into", "collection", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Collection.php#L264-L267
yiisoft/yii2-mongodb
src/Collection.php
Collection.batchInsert
public function batchInsert($rows, $options = []) { $insertedIds = $this->database->createCommand()->batchInsert($this->name, $rows, $options); foreach ($rows as $key => $row) { $rows[$key]['_id'] = $insertedIds[$key]; } return $rows; }
php
public function batchInsert($rows, $options = []) { $insertedIds = $this->database->createCommand()->batchInsert($this->name, $rows, $options); foreach ($rows as $key => $row) { $rows[$key]['_id'] = $insertedIds[$key]; } return $rows; }
[ "public", "function", "batchInsert", "(", "$", "rows", ",", "$", "options", "=", "[", "]", ")", "{", "$", "insertedIds", "=", "$", "this", "->", "database", "->", "createCommand", "(", ")", "->", "batchInsert", "(", "$", "this", "->", "name", ",", "$...
Inserts several new rows into collection. @param array $rows array of arrays or objects to be inserted. @param array $options list of options in format: optionName => optionValue. @return array inserted data, each row will have "_id" key assigned to it. @throws Exception on failure.
[ "Inserts", "several", "new", "rows", "into", "collection", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Collection.php#L276-L283
yiisoft/yii2-mongodb
src/Collection.php
Collection.update
public function update($condition, $newData, $options = []) { $writeResult = $this->database->createCommand()->update($this->name, $condition, $newData, $options); return $writeResult->getModifiedCount() + $writeResult->getUpsertedCount(); }
php
public function update($condition, $newData, $options = []) { $writeResult = $this->database->createCommand()->update($this->name, $condition, $newData, $options); return $writeResult->getModifiedCount() + $writeResult->getUpsertedCount(); }
[ "public", "function", "update", "(", "$", "condition", ",", "$", "newData", ",", "$", "options", "=", "[", "]", ")", "{", "$", "writeResult", "=", "$", "this", "->", "database", "->", "createCommand", "(", ")", "->", "update", "(", "$", "this", "->",...
Updates the rows, which matches given criteria by given data. Note: for "multi" mode Mongo requires explicit strategy "$set" or "$inc" to be specified for the "newData". If no strategy is passed "$set" will be used. @param array $condition description of the objects to update. @param array $newData the object with whic...
[ "Updates", "the", "rows", "which", "matches", "given", "criteria", "by", "given", "data", ".", "Note", ":", "for", "multi", "mode", "Mongo", "requires", "explicit", "strategy", "$set", "or", "$inc", "to", "be", "specified", "for", "the", "newData", ".", "I...
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Collection.php#L295-L299
yiisoft/yii2-mongodb
src/Collection.php
Collection.save
public function save($data, $options = []) { if (empty($data['_id'])) { return $this->insert($data, $options); } $id = $data['_id']; unset($data['_id']); $this->update(['_id' => $id], ['$set' => $data], ['upsert' => true]); return is_object($id) ? $id : n...
php
public function save($data, $options = []) { if (empty($data['_id'])) { return $this->insert($data, $options); } $id = $data['_id']; unset($data['_id']); $this->update(['_id' => $id], ['$set' => $data], ['upsert' => true]); return is_object($id) ? $id : n...
[ "public", "function", "save", "(", "$", "data", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "data", "[", "'_id'", "]", ")", ")", "{", "return", "$", "this", "->", "insert", "(", "$", "data", ",", "$", "options", ...
Update the existing database data, otherwise insert this data @param array|object $data data to be updated/inserted. @param array $options list of options in format: optionName => optionValue. @return \MongoDB\BSON\ObjectID updated/new record id instance. @throws Exception on failure.
[ "Update", "the", "existing", "database", "data", "otherwise", "insert", "this", "data" ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Collection.php#L308-L318
yiisoft/yii2-mongodb
src/Collection.php
Collection.remove
public function remove($condition = [], $options = []) { $options = array_merge(['limit' => 0], $options); $writeResult = $this->database->createCommand()->delete($this->name, $condition, $options); return $writeResult->getDeletedCount(); }
php
public function remove($condition = [], $options = []) { $options = array_merge(['limit' => 0], $options); $writeResult = $this->database->createCommand()->delete($this->name, $condition, $options); return $writeResult->getDeletedCount(); }
[ "public", "function", "remove", "(", "$", "condition", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "array_merge", "(", "[", "'limit'", "=>", "0", "]", ",", "$", "options", ")", ";", "$", "writeResult", "=", "...
Removes data from the collection. @param array $condition description of records to remove. @param array $options list of options in format: optionName => optionValue. @return int|bool number of updated documents or whether operation was successful. @throws Exception on failure.
[ "Removes", "data", "from", "the", "collection", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Collection.php#L327-L332
yiisoft/yii2-mongodb
src/Collection.php
Collection.count
public function count($condition = [], $options = []) { return $this->database->createCommand()->count($this->name, $condition, $options); }
php
public function count($condition = [], $options = []) { return $this->database->createCommand()->count($this->name, $condition, $options); }
[ "public", "function", "count", "(", "$", "condition", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "database", "->", "createCommand", "(", ")", "->", "count", "(", "$", "this", "->", "name", ",", "$", ...
Counts records in this collection. @param array $condition query condition @param array $options list of options in format: optionName => optionValue. @return int records count. @since 2.1
[ "Counts", "records", "in", "this", "collection", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Collection.php#L341-L344
yiisoft/yii2-mongodb
src/Collection.php
Collection.distinct
public function distinct($column, $condition = [], $options = []) { return $this->database->createCommand()->distinct($this->name, $column, $condition, $options); }
php
public function distinct($column, $condition = [], $options = []) { return $this->database->createCommand()->distinct($this->name, $column, $condition, $options); }
[ "public", "function", "distinct", "(", "$", "column", ",", "$", "condition", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "database", "->", "createCommand", "(", ")", "->", "distinct", "(", "$", "this", ...
Returns a list of distinct values for the given column across a collection. @param string $column column to use. @param array $condition query parameters. @param array $options list of options in format: optionName => optionValue. @return array|bool array of distinct values, or "false" on failure. @throws Exception on ...
[ "Returns", "a", "list", "of", "distinct", "values", "for", "the", "given", "column", "across", "a", "collection", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Collection.php#L354-L357
yiisoft/yii2-mongodb
src/Collection.php
Collection.aggregate
public function aggregate($pipelines, $options = []) { return $this->database->createCommand()->aggregate($this->name, $pipelines, $options); }
php
public function aggregate($pipelines, $options = []) { return $this->database->createCommand()->aggregate($this->name, $pipelines, $options); }
[ "public", "function", "aggregate", "(", "$", "pipelines", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "database", "->", "createCommand", "(", ")", "->", "aggregate", "(", "$", "this", "->", "name", ",", "$", "pipelines", ...
Performs aggregation using Mongo Aggregation Framework. In case 'cursor' option is specified [[\MongoDB\Driver\Cursor]] instance is returned, otherwise - an array of aggregation results. @param array $pipelines list of pipeline operators. @param array $options optional parameters. @return array|\MongoDB\Driver\Cursor t...
[ "Performs", "aggregation", "using", "Mongo", "Aggregation", "Framework", ".", "In", "case", "cursor", "option", "is", "specified", "[[", "\\", "MongoDB", "\\", "Driver", "\\", "Cursor", "]]", "instance", "is", "returned", "otherwise", "-", "an", "array", "of",...
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Collection.php#L368-L371
yiisoft/yii2-mongodb
src/Collection.php
Collection.group
public function group($keys, $initial, $reduce, $options = []) { return $this->database->createCommand()->group($this->name, $keys, $initial, $reduce, $options); }
php
public function group($keys, $initial, $reduce, $options = []) { return $this->database->createCommand()->group($this->name, $keys, $initial, $reduce, $options); }
[ "public", "function", "group", "(", "$", "keys", ",", "$", "initial", ",", "$", "reduce", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "database", "->", "createCommand", "(", ")", "->", "group", "(", "$", "this", "->",...
Performs aggregation using Mongo "group" command. @param mixed $keys fields to group by. If an array or non-code object is passed, it will be the key used to group results. If instance of [[\MongoDB\BSON\Javascript]] passed, it will be treated as a function that returns the key to group by. @param array $initial Initia...
[ "Performs", "aggregation", "using", "Mongo", "group", "command", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Collection.php#L388-L391
yiisoft/yii2-mongodb
src/Collection.php
Collection.mapReduce
public function mapReduce($map, $reduce, $out, $condition = [], $options = []) { return $this->database->createCommand()->mapReduce($this->name, $map, $reduce, $out, $condition, $options); }
php
public function mapReduce($map, $reduce, $out, $condition = [], $options = []) { return $this->database->createCommand()->mapReduce($this->name, $map, $reduce, $out, $condition, $options); }
[ "public", "function", "mapReduce", "(", "$", "map", ",", "$", "reduce", ",", "$", "out", ",", "$", "condition", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "database", "->", "createCommand", "(", ")", ...
Performs aggregation using MongoDB "map-reduce" mechanism. Note: this function will not return the aggregation result, instead it will write it inside the another Mongo collection specified by "out" parameter. For example: ```php $customerCollection = Yii::$app->mongo->getCollection('customer'); $resultCollectionName ...
[ "Performs", "aggregation", "using", "MongoDB", "map", "-", "reduce", "mechanism", ".", "Note", ":", "this", "function", "will", "not", "return", "the", "aggregation", "result", "instead", "it", "will", "write", "it", "inside", "the", "another", "Mongo", "colle...
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Collection.php#L432-L435
yiisoft/yii2-mongodb
src/Command.php
Command.getReadPreference
public function getReadPreference() { if (!is_object($this->_readPreference)) { if ($this->_readPreference === null) { $this->_readPreference = $this->db->manager->getReadPreference(); } elseif (is_scalar($this->_readPreference)) { $this->_readPreferen...
php
public function getReadPreference() { if (!is_object($this->_readPreference)) { if ($this->_readPreference === null) { $this->_readPreference = $this->db->manager->getReadPreference(); } elseif (is_scalar($this->_readPreference)) { $this->_readPreferen...
[ "public", "function", "getReadPreference", "(", ")", "{", "if", "(", "!", "is_object", "(", "$", "this", "->", "_readPreference", ")", ")", "{", "if", "(", "$", "this", "->", "_readPreference", "===", "null", ")", "{", "$", "this", "->", "_readPreference...
Returns read preference for this command. @return ReadPreference read preference.
[ "Returns", "read", "preference", "for", "this", "command", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L94-L104
yiisoft/yii2-mongodb
src/Command.php
Command.getWriteConcern
public function getWriteConcern() { if ($this->_writeConcern !== null) { if (is_scalar($this->_writeConcern)) { $this->_writeConcern = new WriteConcern($this->_writeConcern); } } return $this->_writeConcern; }
php
public function getWriteConcern() { if ($this->_writeConcern !== null) { if (is_scalar($this->_writeConcern)) { $this->_writeConcern = new WriteConcern($this->_writeConcern); } } return $this->_writeConcern; }
[ "public", "function", "getWriteConcern", "(", ")", "{", "if", "(", "$", "this", "->", "_writeConcern", "!==", "null", ")", "{", "if", "(", "is_scalar", "(", "$", "this", "->", "_writeConcern", ")", ")", "{", "$", "this", "->", "_writeConcern", "=", "ne...
Returns write concern for this command. @return WriteConcern|null write concern to be used in this command.
[ "Returns", "write", "concern", "for", "this", "command", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L122-L130
yiisoft/yii2-mongodb
src/Command.php
Command.getReadConcern
public function getReadConcern() { if ($this->_readConcern !== null) { if (is_scalar($this->_readConcern)) { $this->_readConcern = new ReadConcern($this->_readConcern); } } return $this->_readConcern; }
php
public function getReadConcern() { if ($this->_readConcern !== null) { if (is_scalar($this->_readConcern)) { $this->_readConcern = new ReadConcern($this->_readConcern); } } return $this->_readConcern; }
[ "public", "function", "getReadConcern", "(", ")", "{", "if", "(", "$", "this", "->", "_readConcern", "!==", "null", ")", "{", "if", "(", "is_scalar", "(", "$", "this", "->", "_readConcern", ")", ")", "{", "$", "this", "->", "_readConcern", "=", "new", ...
Retuns read concern for this command. @return ReadConcern|string read concern to be used in this command.
[ "Retuns", "read", "concern", "for", "this", "command", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L148-L156
yiisoft/yii2-mongodb
src/Command.php
Command.execute
public function execute() { $databaseName = $this->databaseName === null ? $this->db->defaultDatabaseName : $this->databaseName; $token = $this->log([$databaseName, 'command'], $this->document, __METHOD__); try { $this->beginProfile($token, __METHOD__); $this->db->...
php
public function execute() { $databaseName = $this->databaseName === null ? $this->db->defaultDatabaseName : $this->databaseName; $token = $this->log([$databaseName, 'command'], $this->document, __METHOD__); try { $this->beginProfile($token, __METHOD__); $this->db->...
[ "public", "function", "execute", "(", ")", "{", "$", "databaseName", "=", "$", "this", "->", "databaseName", "===", "null", "?", "$", "this", "->", "db", "->", "defaultDatabaseName", ":", "$", "this", "->", "databaseName", ";", "$", "token", "=", "$", ...
Executes this command. @return \MongoDB\Driver\Cursor result cursor. @throws Exception on failure.
[ "Executes", "this", "command", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L175-L196
yiisoft/yii2-mongodb
src/Command.php
Command.executeBatch
public function executeBatch($collectionName, $options = []) { $databaseName = $this->databaseName === null ? $this->db->defaultDatabaseName : $this->databaseName; $token = $this->log([$databaseName, $collectionName, 'bulkWrite'], $this->document, __METHOD__); try { $this->begi...
php
public function executeBatch($collectionName, $options = []) { $databaseName = $this->databaseName === null ? $this->db->defaultDatabaseName : $this->databaseName; $token = $this->log([$databaseName, $collectionName, 'bulkWrite'], $this->document, __METHOD__); try { $this->begi...
[ "public", "function", "executeBatch", "(", "$", "collectionName", ",", "$", "options", "=", "[", "]", ")", "{", "$", "databaseName", "=", "$", "this", "->", "databaseName", "===", "null", "?", "$", "this", "->", "db", "->", "defaultDatabaseName", ":", "$...
Execute commands batch (bulk). @param string $collectionName collection name. @param array $options batch options. @return array array of 2 elements: - 'insertedIds' - contains inserted IDs. - 'result' - [[\MongoDB\Driver\WriteResult]] instance. @throws Exception on failure. @throws InvalidConfigException on invalid ...
[ "Execute", "commands", "batch", "(", "bulk", ")", ".", "@param", "string", "$collectionName", "collection", "name", ".", "@param", "array", "$options", "batch", "options", ".", "@return", "array", "array", "of", "2", "elements", ":" ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L210-L251
yiisoft/yii2-mongodb
src/Command.php
Command.query
public function query($collectionName, $options = []) { $databaseName = $this->databaseName === null ? $this->db->defaultDatabaseName : $this->databaseName; $token = $this->log( 'find', array_merge( [ 'ns' => $databaseName . '.' . $collect...
php
public function query($collectionName, $options = []) { $databaseName = $this->databaseName === null ? $this->db->defaultDatabaseName : $this->databaseName; $token = $this->log( 'find', array_merge( [ 'ns' => $databaseName . '.' . $collect...
[ "public", "function", "query", "(", "$", "collectionName", ",", "$", "options", "=", "[", "]", ")", "{", "$", "databaseName", "=", "$", "this", "->", "databaseName", "===", "null", "?", "$", "this", "->", "db", "->", "defaultDatabaseName", ":", "$", "t...
Executes this command as a mongo query @param string $collectionName collection name @param array $options query options. @return \MongoDB\Driver\Cursor result cursor. @throws Exception on failure
[ "Executes", "this", "command", "as", "a", "mongo", "query" ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L260-L296
yiisoft/yii2-mongodb
src/Command.php
Command.dropDatabase
public function dropDatabase() { $this->document = $this->db->getQueryBuilder()->dropDatabase(); $result = current($this->execute()->toArray()); return $result['ok'] > 0; }
php
public function dropDatabase() { $this->document = $this->db->getQueryBuilder()->dropDatabase(); $result = current($this->execute()->toArray()); return $result['ok'] > 0; }
[ "public", "function", "dropDatabase", "(", ")", "{", "$", "this", "->", "document", "=", "$", "this", "->", "db", "->", "getQueryBuilder", "(", ")", "->", "dropDatabase", "(", ")", ";", "$", "result", "=", "current", "(", "$", "this", "->", "execute", ...
Drops database associated with this command. @return bool whether operation was successful.
[ "Drops", "database", "associated", "with", "this", "command", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L302-L308
yiisoft/yii2-mongodb
src/Command.php
Command.createCollection
public function createCollection($collectionName, array $options = []) { $this->document = $this->db->getQueryBuilder()->createCollection($collectionName, $options); $result = current($this->execute()->toArray()); return $result['ok'] > 0; }
php
public function createCollection($collectionName, array $options = []) { $this->document = $this->db->getQueryBuilder()->createCollection($collectionName, $options); $result = current($this->execute()->toArray()); return $result['ok'] > 0; }
[ "public", "function", "createCollection", "(", "$", "collectionName", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "document", "=", "$", "this", "->", "db", "->", "getQueryBuilder", "(", ")", "->", "createCollection", "(", "$...
Creates new collection in database associated with this command.s @param string $collectionName collection name @param array $options collection options in format: "name" => "value" @return bool whether operation was successful.
[ "Creates", "new", "collection", "in", "database", "associated", "with", "this", "command", ".", "s" ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L316-L322
yiisoft/yii2-mongodb
src/Command.php
Command.dropCollection
public function dropCollection($collectionName) { $this->document = $this->db->getQueryBuilder()->dropCollection($collectionName); $result = current($this->execute()->toArray()); return $result['ok'] > 0; }
php
public function dropCollection($collectionName) { $this->document = $this->db->getQueryBuilder()->dropCollection($collectionName); $result = current($this->execute()->toArray()); return $result['ok'] > 0; }
[ "public", "function", "dropCollection", "(", "$", "collectionName", ")", "{", "$", "this", "->", "document", "=", "$", "this", "->", "db", "->", "getQueryBuilder", "(", ")", "->", "dropCollection", "(", "$", "collectionName", ")", ";", "$", "result", "=", ...
Drops specified collection. @param string $collectionName name of the collection to be dropped. @return bool whether operation was successful.
[ "Drops", "specified", "collection", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L329-L335
yiisoft/yii2-mongodb
src/Command.php
Command.createIndexes
public function createIndexes($collectionName, $indexes) { $this->document = $this->db->getQueryBuilder()->createIndexes($this->databaseName, $collectionName, $indexes); $result = current($this->execute()->toArray()); return $result['ok'] > 0; }
php
public function createIndexes($collectionName, $indexes) { $this->document = $this->db->getQueryBuilder()->createIndexes($this->databaseName, $collectionName, $indexes); $result = current($this->execute()->toArray()); return $result['ok'] > 0; }
[ "public", "function", "createIndexes", "(", "$", "collectionName", ",", "$", "indexes", ")", "{", "$", "this", "->", "document", "=", "$", "this", "->", "db", "->", "getQueryBuilder", "(", ")", "->", "createIndexes", "(", "$", "this", "->", "databaseName",...
Creates indexes in the collection. @param string $collectionName collection name. @param array[] $indexes indexes specification. Each specification should be an array in format: optionName => value The main options are: - keys: array, column names with sort order, to be indexed. This option is mandatory. - unique: boo...
[ "Creates", "indexes", "in", "the", "collection", ".", "@param", "string", "$collectionName", "collection", "name", ".", "@param", "array", "[]", "$indexes", "indexes", "specification", ".", "Each", "specification", "should", "be", "an", "array", "in", "format", ...
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L353-L359
yiisoft/yii2-mongodb
src/Command.php
Command.dropIndexes
public function dropIndexes($collectionName, $indexes) { $this->document = $this->db->getQueryBuilder()->dropIndexes($collectionName, $indexes); return current($this->execute()->toArray()); }
php
public function dropIndexes($collectionName, $indexes) { $this->document = $this->db->getQueryBuilder()->dropIndexes($collectionName, $indexes); return current($this->execute()->toArray()); }
[ "public", "function", "dropIndexes", "(", "$", "collectionName", ",", "$", "indexes", ")", "{", "$", "this", "->", "document", "=", "$", "this", "->", "db", "->", "getQueryBuilder", "(", ")", "->", "dropIndexes", "(", "$", "collectionName", ",", "$", "in...
Drops collection indexes by name. @param string $collectionName collection name. @param string $indexes wildcard for name of the indexes to be dropped. @return array result data.
[ "Drops", "collection", "indexes", "by", "name", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L367-L372
yiisoft/yii2-mongodb
src/Command.php
Command.listIndexes
public function listIndexes($collectionName, $options = []) { $this->document = $this->db->getQueryBuilder()->listIndexes($collectionName, $options); try { $cursor = $this->execute(); } catch (Exception $e) { // The server may return an error if the collection does n...
php
public function listIndexes($collectionName, $options = []) { $this->document = $this->db->getQueryBuilder()->listIndexes($collectionName, $options); try { $cursor = $this->execute(); } catch (Exception $e) { // The server may return an error if the collection does n...
[ "public", "function", "listIndexes", "(", "$", "collectionName", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "document", "=", "$", "this", "->", "db", "->", "getQueryBuilder", "(", ")", "->", "listIndexes", "(", "$", "collectionName"...
Returns information about current collection indexes. @param string $collectionName collection name @param array $options list of options in format: optionName => optionValue. @return array list of indexes info. @throws Exception on failure.
[ "Returns", "information", "about", "current", "collection", "indexes", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L381-L401
yiisoft/yii2-mongodb
src/Command.php
Command.count
public function count($collectionName, $condition = [], $options = []) { $this->document = $this->db->getQueryBuilder()->count($collectionName, $condition, $options); $result = current($this->execute()->toArray()); return $result['n']; }
php
public function count($collectionName, $condition = [], $options = []) { $this->document = $this->db->getQueryBuilder()->count($collectionName, $condition, $options); $result = current($this->execute()->toArray()); return $result['n']; }
[ "public", "function", "count", "(", "$", "collectionName", ",", "$", "condition", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "document", "=", "$", "this", "->", "db", "->", "getQueryBuilder", "(", ")", "->", "co...
Counts records in specified collection. @param string $collectionName collection name @param array $condition filter condition @param array $options list of options in format: optionName => optionValue. @return int records count
[ "Counts", "records", "in", "specified", "collection", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L410-L416
yiisoft/yii2-mongodb
src/Command.php
Command.addUpdate
public function addUpdate($condition, $document, $options = []) { $options = array_merge( [ 'multi' => true, 'upsert' => false, ], $options ); if ($options['multi']) { $keys = array_keys($document); ...
php
public function addUpdate($condition, $document, $options = []) { $options = array_merge( [ 'multi' => true, 'upsert' => false, ], $options ); if ($options['multi']) { $keys = array_keys($document); ...
[ "public", "function", "addUpdate", "(", "$", "condition", ",", "$", "document", ",", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "array_merge", "(", "[", "'multi'", "=>", "true", ",", "'upsert'", "=>", "false", ",", "]", ",", "$", ...
Adds the update operation to the batch command. @param array $condition filter condition @param array $document data to be updated @param array $options update options. @return $this self reference. @see executeBatch()
[ "Adds", "the", "update", "operation", "to", "the", "batch", "command", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L441-L465
yiisoft/yii2-mongodb
src/Command.php
Command.addDelete
public function addDelete($condition, $options = []) { $this->document[] = [ 'type' => 'delete', 'condition' => $this->db->getQueryBuilder()->buildCondition($condition), 'options' => $options, ]; return $this; }
php
public function addDelete($condition, $options = []) { $this->document[] = [ 'type' => 'delete', 'condition' => $this->db->getQueryBuilder()->buildCondition($condition), 'options' => $options, ]; return $this; }
[ "public", "function", "addDelete", "(", "$", "condition", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "document", "[", "]", "=", "[", "'type'", "=>", "'delete'", ",", "'condition'", "=>", "$", "this", "->", "db", "->", "getQueryB...
Adds the delete operation to the batch command. @param array $condition filter condition. @param array $options delete options. @return $this self reference. @see executeBatch()
[ "Adds", "the", "delete", "operation", "to", "the", "batch", "command", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L474-L482
yiisoft/yii2-mongodb
src/Command.php
Command.insert
public function insert($collectionName, $document, $options = []) { $this->document = []; $this->addInsert($document); $result = $this->executeBatch($collectionName, $options); if ($result['result']->getInsertedCount() < 1) { return false; } return reset...
php
public function insert($collectionName, $document, $options = []) { $this->document = []; $this->addInsert($document); $result = $this->executeBatch($collectionName, $options); if ($result['result']->getInsertedCount() < 1) { return false; } return reset...
[ "public", "function", "insert", "(", "$", "collectionName", ",", "$", "document", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "document", "=", "[", "]", ";", "$", "this", "->", "addInsert", "(", "$", "document", ")", ";", "$", ...
Inserts new document into collection. @param string $collectionName collection name @param array $document document content @param array $options list of options in format: optionName => optionValue. @return ObjectID|bool inserted record ID, `false` - on failure.
[ "Inserts", "new", "document", "into", "collection", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L491-L502
yiisoft/yii2-mongodb
src/Command.php
Command.batchInsert
public function batchInsert($collectionName, $documents, $options = []) { $this->document = []; foreach ($documents as $key => $document) { $this->document[$key] = [ 'type' => 'insert', 'document' => $document ]; } $result = $t...
php
public function batchInsert($collectionName, $documents, $options = []) { $this->document = []; foreach ($documents as $key => $document) { $this->document[$key] = [ 'type' => 'insert', 'document' => $document ]; } $result = $t...
[ "public", "function", "batchInsert", "(", "$", "collectionName", ",", "$", "documents", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "document", "=", "[", "]", ";", "foreach", "(", "$", "documents", "as", "$", "key", "=>", "$", ...
Inserts batch of new documents into collection. @param string $collectionName collection name @param array[] $documents documents list @param array $options list of options in format: optionName => optionValue. @return array|false list of inserted IDs, `false` on failure.
[ "Inserts", "batch", "of", "new", "documents", "into", "collection", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L511-L528
yiisoft/yii2-mongodb
src/Command.php
Command.update
public function update($collectionName, $condition, $document, $options = []) { $batchOptions = []; foreach (['bypassDocumentValidation'] as $name) { if (isset($options[$name])) { $batchOptions[$name] = $options[$name]; unset($options[$name]); ...
php
public function update($collectionName, $condition, $document, $options = []) { $batchOptions = []; foreach (['bypassDocumentValidation'] as $name) { if (isset($options[$name])) { $batchOptions[$name] = $options[$name]; unset($options[$name]); ...
[ "public", "function", "update", "(", "$", "collectionName", ",", "$", "condition", ",", "$", "document", ",", "$", "options", "=", "[", "]", ")", "{", "$", "batchOptions", "=", "[", "]", ";", "foreach", "(", "[", "'bypassDocumentValidation'", "]", "as", ...
Update existing documents in the collection. @param string $collectionName collection name @param array $condition filter condition @param array $document data to be updated. @param array $options update options. @return WriteResult write result.
[ "Update", "existing", "documents", "in", "the", "collection", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L538-L553
yiisoft/yii2-mongodb
src/Command.php
Command.delete
public function delete($collectionName, $condition, $options = []) { $batchOptions = []; foreach (['bypassDocumentValidation'] as $name) { if (isset($options[$name])) { $batchOptions[$name] = $options[$name]; unset($options[$name]); } }...
php
public function delete($collectionName, $condition, $options = []) { $batchOptions = []; foreach (['bypassDocumentValidation'] as $name) { if (isset($options[$name])) { $batchOptions[$name] = $options[$name]; unset($options[$name]); } }...
[ "public", "function", "delete", "(", "$", "collectionName", ",", "$", "condition", ",", "$", "options", "=", "[", "]", ")", "{", "$", "batchOptions", "=", "[", "]", ";", "foreach", "(", "[", "'bypassDocumentValidation'", "]", "as", "$", "name", ")", "{...
Removes documents from the collection. @param string $collectionName collection name. @param array $condition filter condition. @param array $options delete options. @return WriteResult write result.
[ "Removes", "documents", "from", "the", "collection", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L562-L577
yiisoft/yii2-mongodb
src/Command.php
Command.find
public function find($collectionName, $condition, $options = []) { $queryBuilder = $this->db->getQueryBuilder(); $this->document = $queryBuilder->buildCondition($condition); if (isset($options['projection'])) { $options['projection'] = $queryBuilder->buildSelectFields($options[...
php
public function find($collectionName, $condition, $options = []) { $queryBuilder = $this->db->getQueryBuilder(); $this->document = $queryBuilder->buildCondition($condition); if (isset($options['projection'])) { $options['projection'] = $queryBuilder->buildSelectFields($options[...
[ "public", "function", "find", "(", "$", "collectionName", ",", "$", "condition", ",", "$", "options", "=", "[", "]", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "db", "->", "getQueryBuilder", "(", ")", ";", "$", "this", "->", "document", "...
Performs find query. @param string $collectionName collection name @param array $condition filter condition @param array $options query options. @return \MongoDB\Driver\Cursor result cursor.
[ "Performs", "find", "query", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L586-L616
yiisoft/yii2-mongodb
src/Command.php
Command.findAndModify
public function findAndModify($collectionName, $condition = [], $update = [], $options = []) { $this->document = $this->db->getQueryBuilder()->findAndModify($collectionName, $condition, $update, $options); $cursor = $this->execute(); $result = current($cursor->toArray()); if (!isse...
php
public function findAndModify($collectionName, $condition = [], $update = [], $options = []) { $this->document = $this->db->getQueryBuilder()->findAndModify($collectionName, $condition, $update, $options); $cursor = $this->execute(); $result = current($cursor->toArray()); if (!isse...
[ "public", "function", "findAndModify", "(", "$", "collectionName", ",", "$", "condition", "=", "[", "]", ",", "$", "update", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "document", "=", "$", "this", "->", "db", ...
Updates a document and returns it. @param $collectionName @param array $condition query condition @param array $update update criteria @param array $options list of options in format: optionName => optionValue. @return array|null the original document, or the modified document when $options['new'] is set.
[ "Updates", "a", "document", "and", "returns", "it", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L626-L638
yiisoft/yii2-mongodb
src/Command.php
Command.distinct
public function distinct($collectionName, $fieldName, $condition = [], $options = []) { $this->document = $this->db->getQueryBuilder()->distinct($collectionName, $fieldName, $condition, $options); $cursor = $this->execute(); $result = current($cursor->toArray()); if (!isset($result...
php
public function distinct($collectionName, $fieldName, $condition = [], $options = []) { $this->document = $this->db->getQueryBuilder()->distinct($collectionName, $fieldName, $condition, $options); $cursor = $this->execute(); $result = current($cursor->toArray()); if (!isset($result...
[ "public", "function", "distinct", "(", "$", "collectionName", ",", "$", "fieldName", ",", "$", "condition", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "document", "=", "$", "this", "->", "db", "->", "getQueryBuild...
Returns a list of distinct values for the given column across a collection. @param string $collectionName collection name. @param string $fieldName field name to use. @param array $condition query parameters. @param array $options list of options in format: optionName => optionValue. @return array array of distinct val...
[ "Returns", "a", "list", "of", "distinct", "values", "for", "the", "given", "column", "across", "a", "collection", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L648-L660
yiisoft/yii2-mongodb
src/Command.php
Command.group
public function group($collectionName, $keys, $initial, $reduce, $options = []) { $this->document = $this->db->getQueryBuilder()->group($collectionName, $keys, $initial, $reduce, $options); $cursor = $this->execute(); $result = current($cursor->toArray()); return $result['retval'];...
php
public function group($collectionName, $keys, $initial, $reduce, $options = []) { $this->document = $this->db->getQueryBuilder()->group($collectionName, $keys, $initial, $reduce, $options); $cursor = $this->execute(); $result = current($cursor->toArray()); return $result['retval'];...
[ "public", "function", "group", "(", "$", "collectionName", ",", "$", "keys", ",", "$", "initial", ",", "$", "reduce", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "document", "=", "$", "this", "->", "db", "->", "getQueryBuilder", ...
Performs aggregation using MongoDB "group" command. @param string $collectionName collection name. @param mixed $keys fields to group by. If an array or non-code object is passed, it will be the key used to group results. If instance of [[\MongoDB\BSON\Javascript]] passed, it will be treated as a function that returns ...
[ "Performs", "aggregation", "using", "MongoDB", "group", "command", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L677-L685
yiisoft/yii2-mongodb
src/Command.php
Command.mapReduce
public function mapReduce($collectionName, $map, $reduce, $out, $condition = [], $options = []) { $this->document = $this->db->getQueryBuilder()->mapReduce($collectionName, $map, $reduce, $out, $condition, $options); $cursor = $this->execute(); $result = current($cursor->toArray()); ...
php
public function mapReduce($collectionName, $map, $reduce, $out, $condition = [], $options = []) { $this->document = $this->db->getQueryBuilder()->mapReduce($collectionName, $map, $reduce, $out, $condition, $options); $cursor = $this->execute(); $result = current($cursor->toArray()); ...
[ "public", "function", "mapReduce", "(", "$", "collectionName", ",", "$", "map", ",", "$", "reduce", ",", "$", "out", ",", "$", "condition", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "document", "=", "$", "thi...
Performs MongoDB "map-reduce" command. @param string $collectionName collection name. @param \MongoDB\BSON\Javascript|string $map function, which emits map data from collection. Argument will be automatically cast to [[\MongoDB\BSON\Javascript]]. @param \MongoDB\BSON\Javascript|string $reduce function that takes two ar...
[ "Performs", "MongoDB", "map", "-", "reduce", "command", ".", "@param", "string", "$collectionName", "collection", "name", ".", "@param", "\\", "MongoDB", "\\", "BSON", "\\", "Javascript|string", "$map", "function", "which", "emits", "map", "data", "from", "colle...
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L710-L718
yiisoft/yii2-mongodb
src/Command.php
Command.aggregate
public function aggregate($collectionName, $pipelines, $options = []) { if (empty($options['cursor'])) { $returnCursor = false; $options['cursor'] = new \stdClass(); } else { $returnCursor = true; } $this->document = $this->db->getQueryBuilder()->...
php
public function aggregate($collectionName, $pipelines, $options = []) { if (empty($options['cursor'])) { $returnCursor = false; $options['cursor'] = new \stdClass(); } else { $returnCursor = true; } $this->document = $this->db->getQueryBuilder()->...
[ "public", "function", "aggregate", "(", "$", "collectionName", ",", "$", "pipelines", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "options", "[", "'cursor'", "]", ")", ")", "{", "$", "returnCursor", "=", "false", ";", ...
Performs aggregation using MongoDB Aggregation Framework. In case 'cursor' option is specified [[\MongoDB\Driver\Cursor]] instance is returned, otherwise - an array of aggregation results. @param string $collectionName collection name @param array $pipelines list of pipeline operators. @param array $options optional pa...
[ "Performs", "aggregation", "using", "MongoDB", "Aggregation", "Framework", ".", "In", "case", "cursor", "option", "is", "specified", "[[", "\\", "MongoDB", "\\", "Driver", "\\", "Cursor", "]]", "instance", "is", "returned", "otherwise", "-", "an", "array", "of...
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L729-L746
yiisoft/yii2-mongodb
src/Command.php
Command.explain
public function explain($collectionName, $query) { $this->document = $this->db->getQueryBuilder()->explain($collectionName, $query); $cursor = $this->execute(); return current($cursor->toArray()); }
php
public function explain($collectionName, $query) { $this->document = $this->db->getQueryBuilder()->explain($collectionName, $query); $cursor = $this->execute(); return current($cursor->toArray()); }
[ "public", "function", "explain", "(", "$", "collectionName", ",", "$", "query", ")", "{", "$", "this", "->", "document", "=", "$", "this", "->", "db", "->", "getQueryBuilder", "(", ")", "->", "explain", "(", "$", "collectionName", ",", "$", "query", ")...
Return an explanation of the query, often useful for optimization and debugging. @param string $collectionName collection name @param array $query query document. @return array explanation of the query.
[ "Return", "an", "explanation", "of", "the", "query", "often", "useful", "for", "optimization", "and", "debugging", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L754-L760
yiisoft/yii2-mongodb
src/Command.php
Command.listDatabases
public function listDatabases($condition = [], $options = []) { if ($this->databaseName === null) { $this->databaseName = 'admin'; } $this->document = $this->db->getQueryBuilder()->listDatabases($condition, $options); $cursor = $this->execute(); $result = current...
php
public function listDatabases($condition = [], $options = []) { if ($this->databaseName === null) { $this->databaseName = 'admin'; } $this->document = $this->db->getQueryBuilder()->listDatabases($condition, $options); $cursor = $this->execute(); $result = current...
[ "public", "function", "listDatabases", "(", "$", "condition", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "databaseName", "===", "null", ")", "{", "$", "this", "->", "databaseName", "=", "'admin'", ";", ...
Returns the list of available databases. @param array $condition filter condition. @param array $options options list. @return array database information
[ "Returns", "the", "list", "of", "available", "databases", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L768-L782
yiisoft/yii2-mongodb
src/Command.php
Command.listCollections
public function listCollections($condition = [], $options = []) { $this->document = $this->db->getQueryBuilder()->listCollections($condition, $options); $cursor = $this->execute(); return $cursor->toArray(); }
php
public function listCollections($condition = [], $options = []) { $this->document = $this->db->getQueryBuilder()->listCollections($condition, $options); $cursor = $this->execute(); return $cursor->toArray(); }
[ "public", "function", "listCollections", "(", "$", "condition", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "document", "=", "$", "this", "->", "db", "->", "getQueryBuilder", "(", ")", "->", "listCollections", "(", ...
Returns the list of available collections. @param array $condition filter condition. @param array $options options list. @return array collections information.
[ "Returns", "the", "list", "of", "available", "collections", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L790-L796
yiisoft/yii2-mongodb
src/Command.php
Command.log
protected function log($namespace, $data, $category) { if ($this->db->enableLogging) { $token = $this->db->getLogBuilder()->generateToken($namespace, $data); Yii::info($token, $category); return $token; } return false; }
php
protected function log($namespace, $data, $category) { if ($this->db->enableLogging) { $token = $this->db->getLogBuilder()->generateToken($namespace, $data); Yii::info($token, $category); return $token; } return false; }
[ "protected", "function", "log", "(", "$", "namespace", ",", "$", "data", ",", "$", "category", ")", "{", "if", "(", "$", "this", "->", "db", "->", "enableLogging", ")", "{", "$", "token", "=", "$", "this", "->", "db", "->", "getLogBuilder", "(", ")...
Logs the command data if logging is enabled at [[db]]. @param array|string $namespace command namespace. @param array $data command data. @param string $category log category @return string|false log token, `false` if log is not enabled.
[ "Logs", "the", "command", "data", "if", "logging", "is", "enabled", "at", "[[", "db", "]]", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L807-L815
yiisoft/yii2-mongodb
src/Command.php
Command.beginProfile
protected function beginProfile($token, $category) { if ($token !== false && $this->db->enableProfiling) { Yii::beginProfile($token, $category); } }
php
protected function beginProfile($token, $category) { if ($token !== false && $this->db->enableProfiling) { Yii::beginProfile($token, $category); } }
[ "protected", "function", "beginProfile", "(", "$", "token", ",", "$", "category", ")", "{", "if", "(", "$", "token", "!==", "false", "&&", "$", "this", "->", "db", "->", "enableProfiling", ")", "{", "Yii", "::", "beginProfile", "(", "$", "token", ",", ...
Marks the beginning of a code block for profiling. @param string $token token for the code block @param string $category the category of this log message @see endProfile()
[ "Marks", "the", "beginning", "of", "a", "code", "block", "for", "profiling", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L823-L828
yiisoft/yii2-mongodb
src/Command.php
Command.endProfile
protected function endProfile($token, $category) { if ($token !== false && $this->db->enableProfiling) { Yii::endProfile($token, $category); } }
php
protected function endProfile($token, $category) { if ($token !== false && $this->db->enableProfiling) { Yii::endProfile($token, $category); } }
[ "protected", "function", "endProfile", "(", "$", "token", ",", "$", "category", ")", "{", "if", "(", "$", "token", "!==", "false", "&&", "$", "this", "->", "db", "->", "enableProfiling", ")", "{", "Yii", "::", "endProfile", "(", "$", "token", ",", "$...
Marks the end of a code block for profiling. @param string $token token for the code block @param string $category the category of this log message @see beginProfile()
[ "Marks", "the", "end", "of", "a", "code", "block", "for", "profiling", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Command.php#L836-L841
yiisoft/yii2-mongodb
src/Cache.php
Cache.getValue
protected function getValue($key) { $query = new Query; $row = $query->select(['data']) ->from($this->cacheCollection) ->where([ 'id' => $key, '$or' => [ [ 'expire' => 0 ], ...
php
protected function getValue($key) { $query = new Query; $row = $query->select(['data']) ->from($this->cacheCollection) ->where([ 'id' => $key, '$or' => [ [ 'expire' => 0 ], ...
[ "protected", "function", "getValue", "(", "$", "key", ")", "{", "$", "query", "=", "new", "Query", ";", "$", "row", "=", "$", "query", "->", "select", "(", "[", "'data'", "]", ")", "->", "from", "(", "$", "this", "->", "cacheCollection", ")", "->",...
Retrieves a value from cache with a specified key. This method should be implemented by child classes to retrieve the data from specific cache storage. @param string $key a unique key identifying the cached value @return string|bool the value stored in cache, false if the value is not in the cache or expired.
[ "Retrieves", "a", "value", "from", "cache", "with", "a", "specified", "key", ".", "This", "method", "should", "be", "implemented", "by", "child", "classes", "to", "retrieve", "the", "data", "from", "specific", "cache", "storage", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Cache.php#L77-L99
yiisoft/yii2-mongodb
src/Cache.php
Cache.setValue
protected function setValue($key, $value, $expire) { $result = $this->db->getCollection($this->cacheCollection) ->update(['id' => $key], [ 'expire' => $expire > 0 ? $expire + time() : 0, 'data' => $value, ]); if ($result) { $this->...
php
protected function setValue($key, $value, $expire) { $result = $this->db->getCollection($this->cacheCollection) ->update(['id' => $key], [ 'expire' => $expire > 0 ? $expire + time() : 0, 'data' => $value, ]); if ($result) { $this->...
[ "protected", "function", "setValue", "(", "$", "key", ",", "$", "value", ",", "$", "expire", ")", "{", "$", "result", "=", "$", "this", "->", "db", "->", "getCollection", "(", "$", "this", "->", "cacheCollection", ")", "->", "update", "(", "[", "'id'...
Stores a value identified by a key in cache. This method should be implemented by child classes to store the data in specific cache storage. @param string $key the key identifying the value to be cached @param string $value the value to be cached @param int $expire the number of seconds in which the cached value will e...
[ "Stores", "a", "value", "identified", "by", "a", "key", "in", "cache", ".", "This", "method", "should", "be", "implemented", "by", "child", "classes", "to", "store", "the", "data", "in", "specific", "cache", "storage", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Cache.php#L110-L123
yiisoft/yii2-mongodb
src/Cache.php
Cache.addValue
protected function addValue($key, $value, $expire) { $this->gc(); if ($expire > 0) { $expire += time(); } else { $expire = 0; } try { $this->db->getCollection($this->cacheCollection) ->insert([ 'id' => ...
php
protected function addValue($key, $value, $expire) { $this->gc(); if ($expire > 0) { $expire += time(); } else { $expire = 0; } try { $this->db->getCollection($this->cacheCollection) ->insert([ 'id' => ...
[ "protected", "function", "addValue", "(", "$", "key", ",", "$", "value", ",", "$", "expire", ")", "{", "$", "this", "->", "gc", "(", ")", ";", "if", "(", "$", "expire", ">", "0", ")", "{", "$", "expire", "+=", "time", "(", ")", ";", "}", "els...
Stores a value identified by a key into cache if the cache does not contain this key. This method should be implemented by child classes to store the data in specific cache storage. @param string $key the key identifying the value to be cached @param string $value the value to be cached @param int $expire the number of...
[ "Stores", "a", "value", "identified", "by", "a", "key", "into", "cache", "if", "the", "cache", "does", "not", "contain", "this", "key", ".", "This", "method", "should", "be", "implemented", "by", "child", "classes", "to", "store", "the", "data", "in", "s...
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Cache.php#L134-L156
yiisoft/yii2-mongodb
src/Cache.php
Cache.deleteValue
protected function deleteValue($key) { $this->db->getCollection($this->cacheCollection)->remove(['id' => $key]); return true; }
php
protected function deleteValue($key) { $this->db->getCollection($this->cacheCollection)->remove(['id' => $key]); return true; }
[ "protected", "function", "deleteValue", "(", "$", "key", ")", "{", "$", "this", "->", "db", "->", "getCollection", "(", "$", "this", "->", "cacheCollection", ")", "->", "remove", "(", "[", "'id'", "=>", "$", "key", "]", ")", ";", "return", "true", ";...
Deletes a value with the specified key from cache This method should be implemented by child classes to delete the data from actual cache storage. @param string $key the key of the value to be deleted @return bool if no error happens during deletion
[ "Deletes", "a", "value", "with", "the", "specified", "key", "from", "cache", "This", "method", "should", "be", "implemented", "by", "child", "classes", "to", "delete", "the", "data", "from", "actual", "cache", "storage", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Cache.php#L164-L168
yiisoft/yii2-mongodb
src/Cache.php
Cache.gc
public function gc($force = false) { if ($force || mt_rand(0, 1000000) < $this->gcProbability) { $this->db->getCollection($this->cacheCollection) ->remove([ 'expire' => [ '$gt' => 0, '$lt' => time(), ...
php
public function gc($force = false) { if ($force || mt_rand(0, 1000000) < $this->gcProbability) { $this->db->getCollection($this->cacheCollection) ->remove([ 'expire' => [ '$gt' => 0, '$lt' => time(), ...
[ "public", "function", "gc", "(", "$", "force", "=", "false", ")", "{", "if", "(", "$", "force", "||", "mt_rand", "(", "0", ",", "1000000", ")", "<", "$", "this", "->", "gcProbability", ")", "{", "$", "this", "->", "db", "->", "getCollection", "(", ...
Removes the expired data values. @param bool $force whether to enforce the garbage collection regardless of [[gcProbability]]. Defaults to false, meaning the actual deletion happens with the probability as specified by [[gcProbability]].
[ "Removes", "the", "expired", "data", "values", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Cache.php#L186-L197
yiisoft/yii2-mongodb
src/file/StreamWrapper.php
StreamWrapper.register
public static function register($protocol = 'gridfs', $force = false) { if (in_array($protocol, stream_get_wrappers())) { if (!$force) { return; } stream_wrapper_unregister($protocol); } stream_wrapper_register($protocol, get_called_class(...
php
public static function register($protocol = 'gridfs', $force = false) { if (in_array($protocol, stream_get_wrappers())) { if (!$force) { return; } stream_wrapper_unregister($protocol); } stream_wrapper_register($protocol, get_called_class(...
[ "public", "static", "function", "register", "(", "$", "protocol", "=", "'gridfs'", ",", "$", "force", "=", "false", ")", "{", "if", "(", "in_array", "(", "$", "protocol", ",", "stream_get_wrappers", "(", ")", ")", ")", "{", "if", "(", "!", "$", "forc...
Registers this steam wrapper. @param string $protocol name of the protocol to be used. @param bool $force whether to register wrapper, even if protocol is already taken.
[ "Registers", "this", "steam", "wrapper", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/file/StreamWrapper.php#L98-L108
yiisoft/yii2-mongodb
src/file/StreamWrapper.php
StreamWrapper.getContextOptions
public function getContextOptions() { if ($this->_contextOptions === null) { $this->_contextOptions = stream_context_get_options($this->context); } return $this->_contextOptions; }
php
public function getContextOptions() { if ($this->_contextOptions === null) { $this->_contextOptions = stream_context_get_options($this->context); } return $this->_contextOptions; }
[ "public", "function", "getContextOptions", "(", ")", "{", "if", "(", "$", "this", "->", "_contextOptions", "===", "null", ")", "{", "$", "this", "->", "_contextOptions", "=", "stream_context_get_options", "(", "$", "this", "->", "context", ")", ";", "}", "...
Returns options associated with [[context]]. @return array context options.
[ "Returns", "options", "associated", "with", "[[", "context", "]]", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/file/StreamWrapper.php#L114-L120
yiisoft/yii2-mongodb
src/file/StreamWrapper.php
StreamWrapper.parsePath
private function parsePath($path) { $pathInfo = parse_url($path); $this->_protocol = $pathInfo['scheme']; $this->_namespace = $pathInfo['host']; parse_str($pathInfo['query'], $this->_queryParams); }
php
private function parsePath($path) { $pathInfo = parse_url($path); $this->_protocol = $pathInfo['scheme']; $this->_namespace = $pathInfo['host']; parse_str($pathInfo['query'], $this->_queryParams); }
[ "private", "function", "parsePath", "(", "$", "path", ")", "{", "$", "pathInfo", "=", "parse_url", "(", "$", "path", ")", ";", "$", "this", "->", "_protocol", "=", "$", "pathInfo", "[", "'scheme'", "]", ";", "$", "this", "->", "_namespace", "=", "$",...
Parses stream open path, initializes internal parameters. @param string $path stream open path.
[ "Parses", "stream", "open", "path", "initializes", "internal", "parameters", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/file/StreamWrapper.php#L126-L133
yiisoft/yii2-mongodb
src/file/StreamWrapper.php
StreamWrapper.prepareDownload
private function prepareDownload() { $contextOptions = $this->getContextOptions(); if (isset($contextOptions[$this->_protocol]['download'])) { $download = $contextOptions[$this->_protocol]['download']; if (!$download instanceof Download) { throw new InvalidCon...
php
private function prepareDownload() { $contextOptions = $this->getContextOptions(); if (isset($contextOptions[$this->_protocol]['download'])) { $download = $contextOptions[$this->_protocol]['download']; if (!$download instanceof Download) { throw new InvalidCon...
[ "private", "function", "prepareDownload", "(", ")", "{", "$", "contextOptions", "=", "$", "this", "->", "getContextOptions", "(", ")", ";", "if", "(", "isset", "(", "$", "contextOptions", "[", "$", "this", "->", "_protocol", "]", "[", "'download'", "]", ...
Prepares [[Download]] instance for the read operations. @return bool success. @throws InvalidConfigException on invalid context configuration.
[ "Prepares", "[[", "Download", "]]", "instance", "for", "the", "read", "operations", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/file/StreamWrapper.php#L140-L163
yiisoft/yii2-mongodb
src/file/StreamWrapper.php
StreamWrapper.prepareUpload
private function prepareUpload() { $contextOptions = $this->getContextOptions(); if (isset($contextOptions[$this->_protocol]['upload'])) { $upload = $contextOptions[$this->_protocol]['upload']; if (!$upload instanceof Upload) { throw new InvalidConfigException...
php
private function prepareUpload() { $contextOptions = $this->getContextOptions(); if (isset($contextOptions[$this->_protocol]['upload'])) { $upload = $contextOptions[$this->_protocol]['upload']; if (!$upload instanceof Upload) { throw new InvalidConfigException...
[ "private", "function", "prepareUpload", "(", ")", "{", "$", "contextOptions", "=", "$", "this", "->", "getContextOptions", "(", ")", ";", "if", "(", "isset", "(", "$", "contextOptions", "[", "$", "this", "->", "_protocol", "]", "[", "'upload'", "]", ")",...
Prepares [[Upload]] instance for the write operations. @return bool success. @throws InvalidConfigException on invalid context configuration.
[ "Prepares", "[[", "Upload", "]]", "instance", "for", "the", "write", "operations", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/file/StreamWrapper.php#L170-L185
yiisoft/yii2-mongodb
src/file/StreamWrapper.php
StreamWrapper.fetchCollection
private function fetchCollection() { $contextOptions = $this->getContextOptions(); if (isset($contextOptions[$this->_protocol]['collection'])) { $collection = $contextOptions[$this->_protocol]['collection']; if ($collection instanceof Collection) { throw new ...
php
private function fetchCollection() { $contextOptions = $this->getContextOptions(); if (isset($contextOptions[$this->_protocol]['collection'])) { $collection = $contextOptions[$this->_protocol]['collection']; if ($collection instanceof Collection) { throw new ...
[ "private", "function", "fetchCollection", "(", ")", "{", "$", "contextOptions", "=", "$", "this", "->", "getContextOptions", "(", ")", ";", "if", "(", "isset", "(", "$", "contextOptions", "[", "$", "this", "->", "_protocol", "]", "[", "'collection'", "]", ...
Fetches associated file collection from stream options. @return Collection file collection instance. @throws InvalidConfigException on invalid stream options.
[ "Fetches", "associated", "file", "collection", "from", "stream", "options", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/file/StreamWrapper.php#L192-L214
yiisoft/yii2-mongodb
src/file/StreamWrapper.php
StreamWrapper.stream_close
public function stream_close() { if ($this->_upload !== null) { $this->_upload->complete(); $this->_upload = null; } if ($this->_download !== null) { $this->_download = null; } }
php
public function stream_close() { if ($this->_upload !== null) { $this->_upload->complete(); $this->_upload = null; } if ($this->_download !== null) { $this->_download = null; } }
[ "public", "function", "stream_close", "(", ")", "{", "if", "(", "$", "this", "->", "_upload", "!==", "null", ")", "{", "$", "this", "->", "_upload", "->", "complete", "(", ")", ";", "$", "this", "->", "_upload", "=", "null", ";", "}", "if", "(", ...
Closes a resource. This method is called in response to `fclose()`. @see fclose()
[ "Closes", "a", "resource", ".", "This", "method", "is", "called", "in", "response", "to", "fclose", "()", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/file/StreamWrapper.php#L247-L256
yiisoft/yii2-mongodb
src/file/StreamWrapper.php
StreamWrapper.stream_eof
public function stream_eof() { return $this->_download !== null ? ($this->_pointerOffset >= $this->_download->getSize()) : true; }
php
public function stream_eof() { return $this->_download !== null ? ($this->_pointerOffset >= $this->_download->getSize()) : true; }
[ "public", "function", "stream_eof", "(", ")", "{", "return", "$", "this", "->", "_download", "!==", "null", "?", "(", "$", "this", "->", "_pointerOffset", ">=", "$", "this", "->", "_download", "->", "getSize", "(", ")", ")", ":", "true", ";", "}" ]
Tests for end-of-file on a file pointer. This method is called in response to `feof()`. @see feof() @return bool `true` if the read/write position is at the end of the stream and if no more data is available to be read, or `false` otherwise.
[ "Tests", "for", "end", "-", "of", "-", "file", "on", "a", "file", "pointer", ".", "This", "method", "is", "called", "in", "response", "to", "feof", "()", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/file/StreamWrapper.php#L265-L270
yiisoft/yii2-mongodb
src/file/StreamWrapper.php
StreamWrapper.stream_open
public function stream_open($path, $mode, $options, &$openedPath) { if ($options & STREAM_USE_PATH) { $openedPath = $path; } $this->parsePath($path); switch ($mode) { case 'r': return $this->prepareDownload(); case 'w': ...
php
public function stream_open($path, $mode, $options, &$openedPath) { if ($options & STREAM_USE_PATH) { $openedPath = $path; } $this->parsePath($path); switch ($mode) { case 'r': return $this->prepareDownload(); case 'w': ...
[ "public", "function", "stream_open", "(", "$", "path", ",", "$", "mode", ",", "$", "options", ",", "&", "$", "openedPath", ")", "{", "if", "(", "$", "options", "&", "STREAM_USE_PATH", ")", "{", "$", "openedPath", "=", "$", "path", ";", "}", "$", "t...
Opens file. This method is called immediately after the wrapper is initialized (f.e. by `fopen()` and `file_get_contents()`). @see fopen() @param string $path specifies the URL that was passed to the original function. @param string $mode mode used to open the file, as detailed for `fopen()`. @param int $options additi...
[ "Opens", "file", ".", "This", "method", "is", "called", "immediately", "after", "the", "wrapper", "is", "initialized", "(", "f", ".", "e", ".", "by", "fopen", "()", "and", "file_get_contents", "()", ")", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/file/StreamWrapper.php#L282-L297
yiisoft/yii2-mongodb
src/file/StreamWrapper.php
StreamWrapper.stream_read
public function stream_read($count) { if ($this->_download === null) { return false; } $result = $this->_download->substr($this->_pointerOffset, $count); $this->_pointerOffset += $count; return $result; }
php
public function stream_read($count) { if ($this->_download === null) { return false; } $result = $this->_download->substr($this->_pointerOffset, $count); $this->_pointerOffset += $count; return $result; }
[ "public", "function", "stream_read", "(", "$", "count", ")", "{", "if", "(", "$", "this", "->", "_download", "===", "null", ")", "{", "return", "false", ";", "}", "$", "result", "=", "$", "this", "->", "_download", "->", "substr", "(", "$", "this", ...
Reads from stream. This method is called in response to `fread()` and `fgets()`. @see fread() @param int $count count of bytes of data from the current position should be returned. @return string|false if there are less than count bytes available, return as many as are available. If no more data is available, return `f...
[ "Reads", "from", "stream", ".", "This", "method", "is", "called", "in", "response", "to", "fread", "()", "and", "fgets", "()", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/file/StreamWrapper.php#L307-L315
yiisoft/yii2-mongodb
src/file/StreamWrapper.php
StreamWrapper.stream_write
public function stream_write($data) { if ($this->_upload === null) { return false; } $this->_upload->addContent($data); $result = StringHelper::byteLength($data); $this->_pointerOffset += $result; return $result; }
php
public function stream_write($data) { if ($this->_upload === null) { return false; } $this->_upload->addContent($data); $result = StringHelper::byteLength($data); $this->_pointerOffset += $result; return $result; }
[ "public", "function", "stream_write", "(", "$", "data", ")", "{", "if", "(", "$", "this", "->", "_upload", "===", "null", ")", "{", "return", "false", ";", "}", "$", "this", "->", "_upload", "->", "addContent", "(", "$", "data", ")", ";", "$", "res...
Writes to stream. This method is called in response to `fwrite()`. @see fwrite() @param string $data string to be stored into the underlying stream. @return int the number of bytes that were successfully stored.
[ "Writes", "to", "stream", ".", "This", "method", "is", "called", "in", "response", "to", "fwrite", "()", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/file/StreamWrapper.php#L324-L333
yiisoft/yii2-mongodb
src/file/StreamWrapper.php
StreamWrapper.stream_stat
public function stream_stat() { $statistics = $this->fileStatisticsTemplate(); if ($this->_download !== null) { $statistics[7] = $statistics['size'] = $this->_download->getSize(); } if ($this->_upload !== null) { $statistics[7] = $statistics['size'] = $this->...
php
public function stream_stat() { $statistics = $this->fileStatisticsTemplate(); if ($this->_download !== null) { $statistics[7] = $statistics['size'] = $this->_download->getSize(); } if ($this->_upload !== null) { $statistics[7] = $statistics['size'] = $this->...
[ "public", "function", "stream_stat", "(", ")", "{", "$", "statistics", "=", "$", "this", "->", "fileStatisticsTemplate", "(", ")", ";", "if", "(", "$", "this", "->", "_download", "!==", "null", ")", "{", "$", "statistics", "[", "7", "]", "=", "$", "s...
Retrieve information about a file resource. This method is called in response to `stat()`. @see stat() @return array file statistic information.
[ "Retrieve", "information", "about", "a", "file", "resource", ".", "This", "method", "is", "called", "in", "response", "to", "stat", "()", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/file/StreamWrapper.php#L352-L364
yiisoft/yii2-mongodb
src/file/StreamWrapper.php
StreamWrapper.stream_seek
public function stream_seek($offset, $whence = SEEK_SET) { switch ($whence) { case SEEK_SET: if ($offset < $this->_download->getSize() && $offset >= 0) { $this->_pointerOffset = $offset; return true; } return...
php
public function stream_seek($offset, $whence = SEEK_SET) { switch ($whence) { case SEEK_SET: if ($offset < $this->_download->getSize() && $offset >= 0) { $this->_pointerOffset = $offset; return true; } return...
[ "public", "function", "stream_seek", "(", "$", "offset", ",", "$", "whence", "=", "SEEK_SET", ")", "{", "switch", "(", "$", "whence", ")", "{", "case", "SEEK_SET", ":", "if", "(", "$", "offset", "<", "$", "this", "->", "_download", "->", "getSize", "...
Seeks to specific location in a stream. This method is called in response to `fseek()`. @see fseek() @param int $offset The stream offset to seek to. @param int $whence Possible values: - SEEK_SET - Set position equal to offset bytes. - SEEK_CUR - Set position to current location plus offset. - SEEK_END - Set position...
[ "Seeks", "to", "specific", "location", "in", "a", "stream", ".", "This", "method", "is", "called", "in", "response", "to", "fseek", "()", ".", "@see", "fseek", "()", "@param", "int", "$offset", "The", "stream", "offset", "to", "seek", "to", ".", "@param"...
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/file/StreamWrapper.php#L380-L403
yiisoft/yii2-mongodb
src/ActiveFixture.php
ActiveFixture.init
public function init() { parent::init(); if (!isset($this->modelClass) && !isset($this->collectionName)) { throw new InvalidConfigException('Either "modelClass" or "collectionName" must be set.'); } }
php
public function init() { parent::init(); if (!isset($this->modelClass) && !isset($this->collectionName)) { throw new InvalidConfigException('Either "modelClass" or "collectionName" must be set.'); } }
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "modelClass", ")", "&&", "!", "isset", "(", "$", "this", "->", "collectionName", ")", ")", "{", "throw", "new", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/ActiveFixture.php#L46-L52
yiisoft/yii2-mongodb
src/ActiveFixture.php
ActiveFixture.load
public function load() { $this->resetCollection(); $this->data = []; $data = $this->getData(); if (empty($data)) { return; } $this->getCollection()->batchInsert($data); foreach ($data as $alias => $row) { $this->data[$alias] = $row; ...
php
public function load() { $this->resetCollection(); $this->data = []; $data = $this->getData(); if (empty($data)) { return; } $this->getCollection()->batchInsert($data); foreach ($data as $alias => $row) { $this->data[$alias] = $row; ...
[ "public", "function", "load", "(", ")", "{", "$", "this", "->", "resetCollection", "(", ")", ";", "$", "this", "->", "data", "=", "[", "]", ";", "$", "data", "=", "$", "this", "->", "getData", "(", ")", ";", "if", "(", "empty", "(", "$", "data"...
Loads the fixture data. The default implementation will first reset the MongoDB collection and then populate it with the data returned by [[getData()]].
[ "Loads", "the", "fixture", "data", ".", "The", "default", "implementation", "will", "first", "reset", "the", "MongoDB", "collection", "and", "then", "populate", "it", "with", "the", "data", "returned", "by", "[[", "getData", "()", "]]", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/ActiveFixture.php#L59-L71
yiisoft/yii2-mongodb
src/ActiveFixture.php
ActiveFixture.getCollectionName
protected function getCollectionName() { if ($this->collectionName) { return $this->collectionName; } /* @var $modelClass ActiveRecord */ $modelClass = $this->modelClass; return $modelClass::collectionName(); }
php
protected function getCollectionName() { if ($this->collectionName) { return $this->collectionName; } /* @var $modelClass ActiveRecord */ $modelClass = $this->modelClass; return $modelClass::collectionName(); }
[ "protected", "function", "getCollectionName", "(", ")", "{", "if", "(", "$", "this", "->", "collectionName", ")", "{", "return", "$", "this", "->", "collectionName", ";", "}", "/* @var $modelClass ActiveRecord */", "$", "modelClass", "=", "$", "this", "->", "m...
Returns collection name used by this fixture. @return array|string related collection name
[ "Returns", "collection", "name", "used", "by", "this", "fixture", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/ActiveFixture.php#L86-L95
yiisoft/yii2-mongodb
src/ActiveFixture.php
ActiveFixture.getData
protected function getData() { if ($this->dataFile === null) { $class = new \ReflectionClass($this); $collectionName = $this->getCollectionName(); $dataFile = dirname($class->getFileName()) . '/data/' . (is_array($collectionName) ? implode('.', $collectionName) : $collec...
php
protected function getData() { if ($this->dataFile === null) { $class = new \ReflectionClass($this); $collectionName = $this->getCollectionName(); $dataFile = dirname($class->getFileName()) . '/data/' . (is_array($collectionName) ? implode('.', $collectionName) : $collec...
[ "protected", "function", "getData", "(", ")", "{", "if", "(", "$", "this", "->", "dataFile", "===", "null", ")", "{", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "$", "this", ")", ";", "$", "collectionName", "=", "$", "this", "->", "getCo...
Returns the fixture data. This method is called by [[loadData()]] to get the needed fixture data. The default implementation will try to return the fixture data by including the external file specified by [[dataFile]]. The file should return an array of data rows (column name => column value), each corresponding to a...
[ "Returns", "the", "fixture", "data", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/ActiveFixture.php#L109-L121
yiisoft/yii2-mongodb
src/i18n/MongoDbMessageSource.php
MongoDbMessageSource.loadMessagesFromDb
protected function loadMessagesFromDb($category, $language) { $fallbackLanguage = substr($language, 0, 2); $fallbackSourceLanguage = substr($this->sourceLanguage, 0, 2); $languages = [ $language, $fallbackLanguage, $fallbackSourceLanguage ]; ...
php
protected function loadMessagesFromDb($category, $language) { $fallbackLanguage = substr($language, 0, 2); $fallbackSourceLanguage = substr($this->sourceLanguage, 0, 2); $languages = [ $language, $fallbackLanguage, $fallbackSourceLanguage ]; ...
[ "protected", "function", "loadMessagesFromDb", "(", "$", "category", ",", "$", "language", ")", "{", "$", "fallbackLanguage", "=", "substr", "(", "$", "language", ",", "0", ",", "2", ")", ";", "$", "fallbackSourceLanguage", "=", "substr", "(", "$", "this",...
Loads the messages from MongoDB. You may override this method to customize the message storage in the MongoDB. @param string $category the message category. @param string $language the target language. @return array the messages loaded from database.
[ "Loads", "the", "messages", "from", "MongoDB", ".", "You", "may", "override", "this", "method", "to", "customize", "the", "message", "storage", "in", "the", "MongoDB", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/i18n/MongoDbMessageSource.php#L162-L214
yiisoft/yii2-mongodb
src/Query.php
Query.getCollection
public function getCollection($db = null) { if ($db === null) { $db = Yii::$app->get('mongodb'); } return $db->getCollection($this->from); }
php
public function getCollection($db = null) { if ($db === null) { $db = Yii::$app->get('mongodb'); } return $db->getCollection($this->from); }
[ "public", "function", "getCollection", "(", "$", "db", "=", "null", ")", "{", "if", "(", "$", "db", "===", "null", ")", "{", "$", "db", "=", "Yii", "::", "$", "app", "->", "get", "(", "'mongodb'", ")", ";", "}", "return", "$", "db", "->", "getC...
Returns the Mongo collection for this query. @param Connection $db Mongo connection. @return Collection collection instance.
[ "Returns", "the", "Mongo", "collection", "for", "this", "query", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Query.php#L69-L76
yiisoft/yii2-mongodb
src/Query.php
Query.addOptions
public function addOptions($options) { if (is_array($this->options)) { $this->options = array_merge($this->options, $options); } else { $this->options = $options; } return $this; }
php
public function addOptions($options) { if (is_array($this->options)) { $this->options = array_merge($this->options, $options); } else { $this->options = $options; } return $this; }
[ "public", "function", "addOptions", "(", "$", "options", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "options", ")", ")", "{", "$", "this", "->", "options", "=", "array_merge", "(", "$", "this", "->", "options", ",", "$", "options", ")",...
Adds additional cursor options. @param array $options cursor options in format: optionName => optionValue @return $this the query object itself @see options()
[ "Adds", "additional", "cursor", "options", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Query.php#L123-L132
yiisoft/yii2-mongodb
src/Query.php
Query.andFilterCompare
public function andFilterCompare($name, $value, $defaultOperator = '=') { $matches = []; if (preg_match('/^(<>|>=|>|<=|<|=)/', $value, $matches)) { $op = $matches[1]; $value = substr($value, strlen($op)); } else { $op = $defaultOperator; } ...
php
public function andFilterCompare($name, $value, $defaultOperator = '=') { $matches = []; if (preg_match('/^(<>|>=|>|<=|<|=)/', $value, $matches)) { $op = $matches[1]; $value = substr($value, strlen($op)); } else { $op = $defaultOperator; } ...
[ "public", "function", "andFilterCompare", "(", "$", "name", ",", "$", "value", ",", "$", "defaultOperator", "=", "'='", ")", "{", "$", "matches", "=", "[", "]", ";", "if", "(", "preg_match", "(", "'/^(<>|>=|>|<=|<|=)/'", ",", "$", "value", ",", "$", "m...
Helper method for easy querying on values containing some common operators. The comparison operator is intelligently determined based on the first few characters in the given value and internally translated to a MongoDB operator. In particular, it recognizes the following operators if they appear as the leading charac...
[ "Helper", "method", "for", "easy", "querying", "on", "values", "containing", "some", "common", "operators", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Query.php#L158-L169
yiisoft/yii2-mongodb
src/Query.php
Query.buildCursor
public function buildCursor($db = null) { $this->prepare(); $options = $this->options; if (!empty($this->orderBy)) { $options['sort'] = $this->orderBy; } $options['limit'] = $this->limit; $options['skip'] = $this->offset; $cursor = $this->getColl...
php
public function buildCursor($db = null) { $this->prepare(); $options = $this->options; if (!empty($this->orderBy)) { $options['sort'] = $this->orderBy; } $options['limit'] = $this->limit; $options['skip'] = $this->offset; $cursor = $this->getColl...
[ "public", "function", "buildCursor", "(", "$", "db", "=", "null", ")", "{", "$", "this", "->", "prepare", "(", ")", ";", "$", "options", "=", "$", "this", "->", "options", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "orderBy", ")", ")",...
Builds the MongoDB cursor for this query. @param Connection $db the MongoDB connection used to execute the query. @return \MongoDB\Driver\Cursor mongo cursor instance.
[ "Builds", "the", "MongoDB", "cursor", "for", "this", "query", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Query.php#L188-L202
yiisoft/yii2-mongodb
src/Query.php
Query.fetchRows
protected function fetchRows($cursor, $all = true, $indexBy = null) { $token = 'fetch cursor id = ' . $cursor->getId(); Yii::info($token, __METHOD__); try { Yii::beginProfile($token, __METHOD__); $result = $this->fetchRowsInternal($cursor, $all); Yii::endP...
php
protected function fetchRows($cursor, $all = true, $indexBy = null) { $token = 'fetch cursor id = ' . $cursor->getId(); Yii::info($token, __METHOD__); try { Yii::beginProfile($token, __METHOD__); $result = $this->fetchRowsInternal($cursor, $all); Yii::endP...
[ "protected", "function", "fetchRows", "(", "$", "cursor", ",", "$", "all", "=", "true", ",", "$", "indexBy", "=", "null", ")", "{", "$", "token", "=", "'fetch cursor id = '", ".", "$", "cursor", "->", "getId", "(", ")", ";", "Yii", "::", "info", "(",...
Fetches rows from the given Mongo cursor. @param \MongoDB\Driver\Cursor $cursor Mongo cursor instance to fetch data from. @param bool $all whether to fetch all rows or only first one. @param string|callable $indexBy the column name or PHP callback, by which the query results should be indexed by. @throws Exception on f...
[ "Fetches", "rows", "from", "the", "given", "Mongo", "cursor", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Query.php#L213-L227
yiisoft/yii2-mongodb
src/Query.php
Query.all
public function all($db = null) { if (!empty($this->emulateExecution)) { return []; } $cursor = $this->buildCursor($db); $rows = $this->fetchRows($cursor, true, $this->indexBy); return $this->populate($rows); }
php
public function all($db = null) { if (!empty($this->emulateExecution)) { return []; } $cursor = $this->buildCursor($db); $rows = $this->fetchRows($cursor, true, $this->indexBy); return $this->populate($rows); }
[ "public", "function", "all", "(", "$", "db", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "emulateExecution", ")", ")", "{", "return", "[", "]", ";", "}", "$", "cursor", "=", "$", "this", "->", "buildCursor", "(", "$", ...
Executes the query and returns all results as an array. @param Connection $db the Mongo connection used to execute the query. If this parameter is not given, the `mongodb` application component will be used. @return array the query results. If the query results in nothing, an empty array will be returned.
[ "Executes", "the", "query", "and", "returns", "all", "results", "as", "an", "array", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Query.php#L320-L328
yiisoft/yii2-mongodb
src/Query.php
Query.one
public function one($db = null) { if (!empty($this->emulateExecution)) { return false; } $cursor = $this->buildCursor($db); return $this->fetchRows($cursor, false); }
php
public function one($db = null) { if (!empty($this->emulateExecution)) { return false; } $cursor = $this->buildCursor($db); return $this->fetchRows($cursor, false); }
[ "public", "function", "one", "(", "$", "db", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "emulateExecution", ")", ")", "{", "return", "false", ";", "}", "$", "cursor", "=", "$", "this", "->", "buildCursor", "(", "$", "...
Executes the query and returns a single row of result. @param Connection $db the Mongo connection used to execute the query. If this parameter is not given, the `mongodb` application component will be used. @return array|false the first row (in terms of an array) of the query result. `false` is returned if the query re...
[ "Executes", "the", "query", "and", "returns", "a", "single", "row", "of", "result", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Query.php#L356-L363
yiisoft/yii2-mongodb
src/Query.php
Query.scalar
public function scalar($db = null) { if (!empty($this->emulateExecution)) { return null; } $originSelect = (array)$this->select; if (!isset($originSelect['_id']) && array_search('_id', $originSelect, true) === false) { $this->select['_id'] = false; } ...
php
public function scalar($db = null) { if (!empty($this->emulateExecution)) { return null; } $originSelect = (array)$this->select; if (!isset($originSelect['_id']) && array_search('_id', $originSelect, true) === false) { $this->select['_id'] = false; } ...
[ "public", "function", "scalar", "(", "$", "db", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "emulateExecution", ")", ")", "{", "return", "null", ";", "}", "$", "originSelect", "=", "(", "array", ")", "$", "this", "->", ...
Returns the query result as a scalar value. The value returned will be the first column in the first row of the query results. Column `_id` will be automatically excluded from select fields, if [[select]] is not empty and `_id` is not selected explicitly. @param Connection $db the MongoDB connection used to generate th...
[ "Returns", "the", "query", "result", "as", "a", "scalar", "value", ".", "The", "value", "returned", "will", "be", "the", "first", "column", "in", "the", "first", "row", "of", "the", "query", "results", ".", "Column", "_id", "will", "be", "automatically", ...
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Query.php#L376-L395
yiisoft/yii2-mongodb
src/Query.php
Query.column
public function column($db = null) { if (!empty($this->emulateExecution)) { return []; } $originSelect = (array)$this->select; if (!isset($originSelect['_id']) && array_search('_id', $originSelect, true) === false) { $this->select['_id'] = false; } ...
php
public function column($db = null) { if (!empty($this->emulateExecution)) { return []; } $originSelect = (array)$this->select; if (!isset($originSelect['_id']) && array_search('_id', $originSelect, true) === false) { $this->select['_id'] = false; } ...
[ "public", "function", "column", "(", "$", "db", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "emulateExecution", ")", ")", "{", "return", "[", "]", ";", "}", "$", "originSelect", "=", "(", "array", ")", "$", "this", "->...
Executes the query and returns the first column of the result. Column `_id` will be automatically excluded from select fields, if [[select]] is not empty and `_id` is not selected explicitly. @param Connection $db the MongoDB connection used to generate the query. If this parameter is not given, the `mongodb` applicati...
[ "Executes", "the", "query", "and", "returns", "the", "first", "column", "of", "the", "result", ".", "Column", "_id", "will", "be", "automatically", "excluded", "from", "select", "fields", "if", "[[", "select", "]]", "is", "not", "empty", "and", "_id", "is"...
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Query.php#L406-L443
yiisoft/yii2-mongodb
src/Query.php
Query.modify
public function modify($update, $options = [], $db = null) { if (!empty($this->emulateExecution)) { return null; } $this->prepare(); $collection = $this->getCollection($db); if (!empty($this->orderBy)) { $options['sort'] = $this->orderBy; } ...
php
public function modify($update, $options = [], $db = null) { if (!empty($this->emulateExecution)) { return null; } $this->prepare(); $collection = $this->getCollection($db); if (!empty($this->orderBy)) { $options['sort'] = $this->orderBy; } ...
[ "public", "function", "modify", "(", "$", "update", ",", "$", "options", "=", "[", "]", ",", "$", "db", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "emulateExecution", ")", ")", "{", "return", "null", ";", "}", "$", ...
Performs 'findAndModify' query and returns a single row of result. @param array $update update criteria @param array $options list of options in format: optionName => optionValue. @param Connection $db the Mongo connection used to execute the query. @return array|null the original document, or the modified document whe...
[ "Performs", "findAndModify", "query", "and", "returns", "a", "single", "row", "of", "result", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Query.php#L452-L467
yiisoft/yii2-mongodb
src/Query.php
Query.count
public function count($q = '*', $db = null) { if (!empty($this->emulateExecution)) { return 0; } $this->prepare(); $collection = $this->getCollection($db); return $collection->count($this->where, $this->options); }
php
public function count($q = '*', $db = null) { if (!empty($this->emulateExecution)) { return 0; } $this->prepare(); $collection = $this->getCollection($db); return $collection->count($this->where, $this->options); }
[ "public", "function", "count", "(", "$", "q", "=", "'*'", ",", "$", "db", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "emulateExecution", ")", ")", "{", "return", "0", ";", "}", "$", "this", "->", "prepare", "(", ")"...
Returns the number of records. @param string $q kept to match [[QueryInterface]], its value is ignored. @param Connection $db the Mongo connection used to execute the query. If this parameter is not given, the `mongodb` application component will be used. @return int number of records @throws Exception on failure.
[ "Returns", "the", "number", "of", "records", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Query.php#L477-L485
yiisoft/yii2-mongodb
src/Query.php
Query.exists
public function exists($db = null) { if (!empty($this->emulateExecution)) { return false; } $cursor = $this->buildCursor($db); foreach ($cursor as $row) { return true; } return false; }
php
public function exists($db = null) { if (!empty($this->emulateExecution)) { return false; } $cursor = $this->buildCursor($db); foreach ($cursor as $row) { return true; } return false; }
[ "public", "function", "exists", "(", "$", "db", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "emulateExecution", ")", ")", "{", "return", "false", ";", "}", "$", "cursor", "=", "$", "this", "->", "buildCursor", "(", "$", ...
Returns a value indicating whether the query result contains any row of data. @param Connection $db the Mongo connection used to execute the query. If this parameter is not given, the `mongodb` application component will be used. @return bool whether the query result contains any row of data.
[ "Returns", "a", "value", "indicating", "whether", "the", "query", "result", "contains", "any", "row", "of", "data", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Query.php#L493-L503
yiisoft/yii2-mongodb
src/Query.php
Query.sum
public function sum($q, $db = null) { if (!empty($this->emulateExecution)) { return 0; } return $this->aggregate($q, 'sum', $db); }
php
public function sum($q, $db = null) { if (!empty($this->emulateExecution)) { return 0; } return $this->aggregate($q, 'sum', $db); }
[ "public", "function", "sum", "(", "$", "q", ",", "$", "db", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "emulateExecution", ")", ")", "{", "return", "0", ";", "}", "return", "$", "this", "->", "aggregate", "(", "$", ...
Returns the sum of the specified column values. @param string $q the column name. Make sure you properly quote column names in the expression. @param Connection $db the Mongo connection used to execute the query. If this parameter is not given, the `mongodb` application component will be used. @return int the sum of th...
[ "Returns", "the", "sum", "of", "the", "specified", "column", "values", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Query.php#L513-L519
yiisoft/yii2-mongodb
src/Query.php
Query.average
public function average($q, $db = null) { if (!empty($this->emulateExecution)) { return 0; } return $this->aggregate($q, 'avg', $db); }
php
public function average($q, $db = null) { if (!empty($this->emulateExecution)) { return 0; } return $this->aggregate($q, 'avg', $db); }
[ "public", "function", "average", "(", "$", "q", ",", "$", "db", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "emulateExecution", ")", ")", "{", "return", "0", ";", "}", "return", "$", "this", "->", "aggregate", "(", "$"...
Returns the average of the specified column values. @param string $q the column name. Make sure you properly quote column names in the expression. @param Connection $db the Mongo connection used to execute the query. If this parameter is not given, the `mongodb` application component will be used. @return int the avera...
[ "Returns", "the", "average", "of", "the", "specified", "column", "values", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Query.php#L529-L535
yiisoft/yii2-mongodb
src/Query.php
Query.aggregate
protected function aggregate($column, $operator, $db) { if (!empty($this->emulateExecution)) { return null; } $this->prepare(); $collection = $this->getCollection($db); $pipelines = []; if ($this->where !== null) { $pipelines[] = ['$match' => ...
php
protected function aggregate($column, $operator, $db) { if (!empty($this->emulateExecution)) { return null; } $this->prepare(); $collection = $this->getCollection($db); $pipelines = []; if ($this->where !== null) { $pipelines[] = ['$match' => ...
[ "protected", "function", "aggregate", "(", "$", "column", ",", "$", "operator", ",", "$", "db", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "emulateExecution", ")", ")", "{", "return", "null", ";", "}", "$", "this", "->", "prepare", ...
Performs the aggregation for the given column. @param string $column column name. @param string $operator aggregation operator. @param Connection $db the database connection used to execute the query. @return int aggregation result.
[ "Performs", "the", "aggregation", "for", "the", "given", "column", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Query.php#L570-L595
yiisoft/yii2-mongodb
src/Query.php
Query.distinct
public function distinct($q, $db = null) { if (!empty($this->emulateExecution)) { return []; } $this->prepare(); $collection = $this->getCollection($db); if ($this->where !== null) { $condition = $this->where; } else { $condition =...
php
public function distinct($q, $db = null) { if (!empty($this->emulateExecution)) { return []; } $this->prepare(); $collection = $this->getCollection($db); if ($this->where !== null) { $condition = $this->where; } else { $condition =...
[ "public", "function", "distinct", "(", "$", "q", ",", "$", "db", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "emulateExecution", ")", ")", "{", "return", "[", "]", ";", "}", "$", "this", "->", "prepare", "(", ")", ";...
Returns a list of distinct values for the given column across a collection. @param string $q column to use. @param Connection $db the MongoDB connection used to execute the query. If this parameter is not given, the `mongodb` application component will be used. @return array array of distinct values
[ "Returns", "a", "list", "of", "distinct", "values", "for", "the", "given", "column", "across", "a", "collection", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/Query.php#L604-L622
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.createCollection
public function createCollection($collectionName, array $options = []) { $document = array_merge(['create' => $collectionName], $options); if (isset($document['indexOptionDefaults'])) { $document['indexOptionDefaults'] = (object) $document['indexOptionDefaults']; } if (i...
php
public function createCollection($collectionName, array $options = []) { $document = array_merge(['create' => $collectionName], $options); if (isset($document['indexOptionDefaults'])) { $document['indexOptionDefaults'] = (object) $document['indexOptionDefaults']; } if (i...
[ "public", "function", "createCollection", "(", "$", "collectionName", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "document", "=", "array_merge", "(", "[", "'create'", "=>", "$", "collectionName", "]", ",", "$", "options", ")", ";", "if",...
Generates 'create collection' command. https://docs.mongodb.com/manual/reference/method/db.createCollection/ @param string $collectionName collection name. @param array $options collection options in format: "name" => "value" @return array command document.
[ "Generates", "create", "collection", "command", ".", "https", ":", "//", "docs", ".", "mongodb", ".", "com", "/", "manual", "/", "reference", "/", "method", "/", "db", ".", "createCollection", "/" ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L85-L100
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.createIndexes
public function createIndexes($databaseName, $collectionName, $indexes) { $normalizedIndexes = []; foreach ($indexes as $index) { if (!isset($index['key'])) { throw new InvalidParamException('"key" is required for index specification'); } $index[...
php
public function createIndexes($databaseName, $collectionName, $indexes) { $normalizedIndexes = []; foreach ($indexes as $index) { if (!isset($index['key'])) { throw new InvalidParamException('"key" is required for index specification'); } $index[...
[ "public", "function", "createIndexes", "(", "$", "databaseName", ",", "$", "collectionName", ",", "$", "indexes", ")", "{", "$", "normalizedIndexes", "=", "[", "]", ";", "foreach", "(", "$", "indexes", "as", "$", "index", ")", "{", "if", "(", "!", "iss...
Generates create indexes command. @see https://docs.mongodb.com/manual/reference/method/db.collection.createIndex/ @param string|null $databaseName database name. @param string $collectionName collection name. @param array[] $indexes indexes specification. Each specification should be an array in format: optionName => ...
[ "Generates", "create", "indexes", "command", ".", "@see", "https", ":", "//", "docs", ".", "mongodb", ".", "com", "/", "manual", "/", "reference", "/", "method", "/", "db", ".", "collection", ".", "createIndex", "/", "@param", "string|null", "$databaseName",...
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L141-L170
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.generateIndexName
public function generateIndexName($columns) { $parts = []; foreach ($columns as $column => $order) { $parts[] = $column . '_' . $order; } return implode('_', $parts); }
php
public function generateIndexName($columns) { $parts = []; foreach ($columns as $column => $order) { $parts[] = $column . '_' . $order; } return implode('_', $parts); }
[ "public", "function", "generateIndexName", "(", "$", "columns", ")", "{", "$", "parts", "=", "[", "]", ";", "foreach", "(", "$", "columns", "as", "$", "column", "=>", "$", "order", ")", "{", "$", "parts", "[", "]", "=", "$", "column", ".", "'_'", ...
Generates index name for the given column orders. Columns should be normalized using [[buildSortFields()]] before being passed to this method. @param array $columns columns with sort order. @return string index name.
[ "Generates", "index", "name", "for", "the", "given", "column", "orders", ".", "Columns", "should", "be", "normalized", "using", "[[", "buildSortFields", "()", "]]", "before", "being", "passed", "to", "this", "method", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L178-L185
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.count
public function count($collectionName, $condition = [], $options = []) { $document = ['count' => $collectionName]; if (!empty($condition)) { $document['query'] = (object) $this->buildCondition($condition); } return array_merge($document, $options); }
php
public function count($collectionName, $condition = [], $options = []) { $document = ['count' => $collectionName]; if (!empty($condition)) { $document['query'] = (object) $this->buildCondition($condition); } return array_merge($document, $options); }
[ "public", "function", "count", "(", "$", "collectionName", ",", "$", "condition", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "$", "document", "=", "[", "'count'", "=>", "$", "collectionName", "]", ";", "if", "(", "!", "empty", "("...
Generates count command @param string $collectionName @param array $condition @param array $options @return array command document.
[ "Generates", "count", "command" ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L223-L232
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.findAndModify
public function findAndModify($collectionName, $condition = [], $update = [], $options = []) { $document = array_merge(['findAndModify' => $collectionName], $options); if (!empty($condition)) { $options['query'] = $this->buildCondition($condition); } if (!empty($update)...
php
public function findAndModify($collectionName, $condition = [], $update = [], $options = []) { $document = array_merge(['findAndModify' => $collectionName], $options); if (!empty($condition)) { $options['query'] = $this->buildCondition($condition); } if (!empty($update)...
[ "public", "function", "findAndModify", "(", "$", "collectionName", ",", "$", "condition", "=", "[", "]", ",", "$", "update", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "$", "document", "=", "array_merge", "(", "[", "'findAndModify'", ...
Generates 'find and modify' command. @param string $collectionName collection name @param array $condition filter condition @param array $update update criteria @param array $options list of options in format: optionName => optionValue. @return array command document.
[ "Generates", "find", "and", "modify", "command", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L242-L269
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.distinct
public function distinct($collectionName, $fieldName, $condition = [], $options = []) { $document = array_merge( [ 'distinct' => $collectionName, 'key' => $fieldName, ], $options ); if (!empty($condition)) { $do...
php
public function distinct($collectionName, $fieldName, $condition = [], $options = []) { $document = array_merge( [ 'distinct' => $collectionName, 'key' => $fieldName, ], $options ); if (!empty($condition)) { $do...
[ "public", "function", "distinct", "(", "$", "collectionName", ",", "$", "fieldName", ",", "$", "condition", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "$", "document", "=", "array_merge", "(", "[", "'distinct'", "=>", "$", "collection...
Generates 'distinct' command. @param string $collectionName collection name. @param string $fieldName target field name. @param array $condition filter condition @param array $options list of options in format: optionName => optionValue. @return array command document.
[ "Generates", "distinct", "command", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L279-L294
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.group
public function group($collectionName, $keys, $initial, $reduce, $options = []) { if (!($reduce instanceof Javascript)) { $reduce = new Javascript((string) $reduce); } if (isset($options['condition'])) { $options['cond'] = $this->buildCondition($options['condition'])...
php
public function group($collectionName, $keys, $initial, $reduce, $options = []) { if (!($reduce instanceof Javascript)) { $reduce = new Javascript((string) $reduce); } if (isset($options['condition'])) { $options['cond'] = $this->buildCondition($options['condition'])...
[ "public", "function", "group", "(", "$", "collectionName", ",", "$", "keys", ",", "$", "initial", ",", "$", "reduce", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "(", "$", "reduce", "instanceof", "Javascript", ")", ")", "{", "$", ...
Generates 'group' command. @param string $collectionName @@param mixed $keys fields to group by. If an array or non-code object is passed, it will be the key used to group results. If instance of [[Javascript]] passed, it will be treated as a function that returns the key to group by. @param array $initial Initial valu...
[ "Generates", "group", "command", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L311-L351
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.mapReduce
public function mapReduce($collectionName, $map, $reduce, $out, $condition = [], $options = []) { if (!($map instanceof Javascript)) { $map = new Javascript((string) $map); } if (!($reduce instanceof Javascript)) { $reduce = new Javascript((string) $reduce); }...
php
public function mapReduce($collectionName, $map, $reduce, $out, $condition = [], $options = []) { if (!($map instanceof Javascript)) { $map = new Javascript((string) $map); } if (!($reduce instanceof Javascript)) { $reduce = new Javascript((string) $reduce); }...
[ "public", "function", "mapReduce", "(", "$", "collectionName", ",", "$", "map", ",", "$", "reduce", ",", "$", "out", ",", "$", "condition", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "(", "$", "map", "instanceof"...
Generates 'map-reduce' command. @see https://docs.mongodb.com/manual/core/map-reduce/ @param string $collectionName collection name. @param \MongoDB\BSON\Javascript|string $map function, which emits map data from collection. Argument will be automatically cast to [[\MongoDB\BSON\Javascript]]. @param \MongoDB\BSON\Javas...
[ "Generates", "map", "-", "reduce", "command", ".", "@see", "https", ":", "//", "docs", ".", "mongodb", ".", "com", "/", "manual", "/", "core", "/", "map", "-", "reduce", "/", "@param", "string", "$collectionName", "collection", "name", ".", "@param", "\\...
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L377-L402
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.aggregate
public function aggregate($collectionName, $pipelines, $options = []) { foreach ($pipelines as $key => $pipeline) { if (isset($pipeline['$match'])) { $pipelines[$key]['$match'] = $this->buildCondition($pipeline['$match']); } } $document = array_merge(...
php
public function aggregate($collectionName, $pipelines, $options = []) { foreach ($pipelines as $key => $pipeline) { if (isset($pipeline['$match'])) { $pipelines[$key]['$match'] = $this->buildCondition($pipeline['$match']); } } $document = array_merge(...
[ "public", "function", "aggregate", "(", "$", "collectionName", ",", "$", "pipelines", ",", "$", "options", "=", "[", "]", ")", "{", "foreach", "(", "$", "pipelines", "as", "$", "key", "=>", "$", "pipeline", ")", "{", "if", "(", "isset", "(", "$", "...
Generates 'aggregate' command. @param string $collectionName collection name @param array $pipelines list of pipeline operators. @param array $options optional parameters. @return array command document.
[ "Generates", "aggregate", "command", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L411-L429
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.explain
public function explain($collectionName, $query) { $query = array_merge( ['find' => $collectionName], $query ); if (isset($query['filter'])) { $query['filter'] = (object) $this->buildCondition($query['filter']); } if (isset($query['project...
php
public function explain($collectionName, $query) { $query = array_merge( ['find' => $collectionName], $query ); if (isset($query['filter'])) { $query['filter'] = (object) $this->buildCondition($query['filter']); } if (isset($query['project...
[ "public", "function", "explain", "(", "$", "collectionName", ",", "$", "query", ")", "{", "$", "query", "=", "array_merge", "(", "[", "'find'", "=>", "$", "collectionName", "]", ",", "$", "query", ")", ";", "if", "(", "isset", "(", "$", "query", "[",...
Generates 'explain' command. @param string $collectionName collection name. @param array $query query options. @return array command document.
[ "Generates", "explain", "command", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L437-L457
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.listDatabases
public function listDatabases($condition = [], $options = []) { $document = array_merge(['listDatabases' => 1], $options); if (!empty($condition)) { $document['filter'] = (object)$this->buildCondition($condition); } return $document; }
php
public function listDatabases($condition = [], $options = []) { $document = array_merge(['listDatabases' => 1], $options); if (!empty($condition)) { $document['filter'] = (object)$this->buildCondition($condition); } return $document; }
[ "public", "function", "listDatabases", "(", "$", "condition", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "$", "document", "=", "array_merge", "(", "[", "'listDatabases'", "=>", "1", "]", ",", "$", "options", ")", ";", "if", "(", "...
Generates 'listDatabases' command. @param array $condition filter condition. @param array $options command options. @return array command document.
[ "Generates", "listDatabases", "command", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L465-L472
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.buildSelectFields
public function buildSelectFields($fields) { $selectFields = []; foreach ((array)$fields as $key => $value) { if (is_int($key)) { $selectFields[$value] = true; } else { $selectFields[$key] = is_scalar($value) ? (bool)$value : $value; ...
php
public function buildSelectFields($fields) { $selectFields = []; foreach ((array)$fields as $key => $value) { if (is_int($key)) { $selectFields[$value] = true; } else { $selectFields[$key] = is_scalar($value) ? (bool)$value : $value; ...
[ "public", "function", "buildSelectFields", "(", "$", "fields", ")", "{", "$", "selectFields", "=", "[", "]", ";", "foreach", "(", "(", "array", ")", "$", "fields", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_int", "(", "$", "key"...
Normalizes fields list for the MongoDB select composition. @param array|string $fields raw fields. @return array normalized select fields.
[ "Normalizes", "fields", "list", "for", "the", "MongoDB", "select", "composition", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L496-L507
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.buildSortFields
public function buildSortFields($fields) { $sortFields = []; foreach ((array)$fields as $key => $value) { if (is_int($key)) { $sortFields[$value] = +1; } else { if ($value === SORT_ASC) { $value = +1; } elsei...
php
public function buildSortFields($fields) { $sortFields = []; foreach ((array)$fields as $key => $value) { if (is_int($key)) { $sortFields[$value] = +1; } else { if ($value === SORT_ASC) { $value = +1; } elsei...
[ "public", "function", "buildSortFields", "(", "$", "fields", ")", "{", "$", "sortFields", "=", "[", "]", ";", "foreach", "(", "(", "array", ")", "$", "fields", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_int", "(", "$", "key", ...
Normalizes fields list for the MongoDB sort composition. @param array|string $fields raw fields. @return array normalized sort fields.
[ "Normalizes", "fields", "list", "for", "the", "MongoDB", "sort", "composition", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L514-L530
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.normalizeConditionKeyword
protected function normalizeConditionKeyword($key) { static $map = [ 'AND' => '$and', 'OR' => '$or', 'IN' => '$in', 'NOT IN' => '$nin', ]; $matchKey = strtoupper($key); if (array_key_exists($matchKey, $map)) { return $map[$m...
php
protected function normalizeConditionKeyword($key) { static $map = [ 'AND' => '$and', 'OR' => '$or', 'IN' => '$in', 'NOT IN' => '$nin', ]; $matchKey = strtoupper($key); if (array_key_exists($matchKey, $map)) { return $map[$m...
[ "protected", "function", "normalizeConditionKeyword", "(", "$", "key", ")", "{", "static", "$", "map", "=", "[", "'AND'", "=>", "'$and'", ",", "'OR'", "=>", "'$or'", ",", "'IN'", "=>", "'$in'", ",", "'NOT IN'", "=>", "'$nin'", ",", "]", ";", "$", "matc...
Converts "\yii\db\*" quick condition keyword into actual Mongo condition keyword. @param string $key raw condition key. @return string actual key.
[ "Converts", "\\", "yii", "\\", "db", "\\", "*", "quick", "condition", "keyword", "into", "actual", "Mongo", "condition", "keyword", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L537-L550
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.ensureMongoId
protected function ensureMongoId($rawId) { if (is_array($rawId)) { $result = []; foreach ($rawId as $key => $value) { $result[$key] = $this->ensureMongoId($value); } return $result; } elseif (is_object($rawId)) { if ($rawId...
php
protected function ensureMongoId($rawId) { if (is_array($rawId)) { $result = []; foreach ($rawId as $key => $value) { $result[$key] = $this->ensureMongoId($value); } return $result; } elseif (is_object($rawId)) { if ($rawId...
[ "protected", "function", "ensureMongoId", "(", "$", "rawId", ")", "{", "if", "(", "is_array", "(", "$", "rawId", ")", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "rawId", "as", "$", "key", "=>", "$", "value", ")", "{", "$", ...
Converts given value into [[ObjectID]] instance. If array given, each element of it will be processed. @param mixed $rawId raw id(s). @return array|ObjectID normalized id(s).
[ "Converts", "given", "value", "into", "[[", "ObjectID", "]]", "instance", ".", "If", "array", "given", "each", "element", "of", "it", "will", "be", "processed", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L558-L582
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.buildCondition
public function buildCondition($condition) { static $builders = [ 'NOT' => 'buildNotCondition', 'AND' => 'buildAndCondition', 'OR' => 'buildOrCondition', 'BETWEEN' => 'buildBetweenCondition', 'NOT BETWEEN' => 'buildBetweenCondition', 'I...
php
public function buildCondition($condition) { static $builders = [ 'NOT' => 'buildNotCondition', 'AND' => 'buildAndCondition', 'OR' => 'buildOrCondition', 'BETWEEN' => 'buildBetweenCondition', 'NOT BETWEEN' => 'buildBetweenCondition', 'I...
[ "public", "function", "buildCondition", "(", "$", "condition", ")", "{", "static", "$", "builders", "=", "[", "'NOT'", "=>", "'buildNotCondition'", ",", "'AND'", "=>", "'buildAndCondition'", ",", "'OR'", "=>", "'buildOrCondition'", ",", "'BETWEEN'", "=>", "'buil...
Parses the condition specification and generates the corresponding Mongo condition. @param array $condition the condition specification. Please refer to [[Query::where()]] on how to specify a condition. @return array the generated Mongo condition @throws InvalidParamException if the condition is in bad format
[ "Parses", "the", "condition", "specification", "and", "generates", "the", "corresponding", "Mongo", "condition", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L591-L623
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.buildHashCondition
public function buildHashCondition($condition) { $result = []; foreach ($condition as $name => $value) { if (strncmp('$', $name, 1) === 0) { // Native Mongo condition: $result[$name] = $value; } else { if (is_array($value)) { ...
php
public function buildHashCondition($condition) { $result = []; foreach ($condition as $name => $value) { if (strncmp('$', $name, 1) === 0) { // Native Mongo condition: $result[$name] = $value; } else { if (is_array($value)) { ...
[ "public", "function", "buildHashCondition", "(", "$", "condition", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "condition", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "strncmp", "(", "'$'", ",", "$", "name", "...
Creates a condition based on column-value pairs. @param array $condition the condition specification. @return array the generated Mongo condition.
[ "Creates", "a", "condition", "based", "on", "column", "-", "value", "pairs", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L630-L657
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.buildNotCondition
public function buildNotCondition($operator, $operands) { if (count($operands) !== 2) { throw new InvalidParamException("Operator '$operator' requires two operands."); } list($name, $value) = $operands; $result = []; if (is_array($value)) { $result[$...
php
public function buildNotCondition($operator, $operands) { if (count($operands) !== 2) { throw new InvalidParamException("Operator '$operator' requires two operands."); } list($name, $value) = $operands; $result = []; if (is_array($value)) { $result[$...
[ "public", "function", "buildNotCondition", "(", "$", "operator", ",", "$", "operands", ")", "{", "if", "(", "count", "(", "$", "operands", ")", "!==", "2", ")", "{", "throw", "new", "InvalidParamException", "(", "\"Operator '$operator' requires two operands.\"", ...
Composes `NOT` condition. @param string $operator the operator to use for connecting the given operands @param array $operands the Mongo conditions to connect. @return array the generated Mongo condition. @throws InvalidParamException if wrong number of operands have been given.
[ "Composes", "NOT", "condition", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L666-L685
yiisoft/yii2-mongodb
src/QueryBuilder.php
QueryBuilder.buildAndCondition
public function buildAndCondition($operator, $operands) { $operator = $this->normalizeConditionKeyword($operator); $parts = []; foreach ($operands as $operand) { $parts[] = $this->buildCondition($operand); } return [$operator => $parts]; }
php
public function buildAndCondition($operator, $operands) { $operator = $this->normalizeConditionKeyword($operator); $parts = []; foreach ($operands as $operand) { $parts[] = $this->buildCondition($operand); } return [$operator => $parts]; }
[ "public", "function", "buildAndCondition", "(", "$", "operator", ",", "$", "operands", ")", "{", "$", "operator", "=", "$", "this", "->", "normalizeConditionKeyword", "(", "$", "operator", ")", ";", "$", "parts", "=", "[", "]", ";", "foreach", "(", "$", ...
Connects two or more conditions with the `AND` operator. @param string $operator the operator to use for connecting the given operands @param array $operands the Mongo conditions to connect. @return array the generated Mongo condition.
[ "Connects", "two", "or", "more", "conditions", "with", "the", "AND", "operator", "." ]
train
https://github.com/yiisoft/yii2-mongodb/blob/7f8d9862ac6c133d63afda171860ca9b61563d27/src/QueryBuilder.php#L693-L702