K
K
Khurshed Abdujalil2017-04-28 15:20:12
Yii
Khurshed Abdujalil, 2017-04-28 15:20:12

How to fix Detected corrupt BSON data error?

made a request in the console

db.company.aggregate([{$group : {_id : {$substr: ["$name", 0,1]}}}])

everything works fine, records are displayed
rewrote to yii2
$collection = Yii::$app->mongodb->getCollection('company');
        $result = $collection->aggregate(array(
                array(
                    '$group' => array(
                        '_id' => array('$substr' => ['$name', 0, 1]),
                    ),
                ),
            )
        );

displays the error Detected corrupt BSON data and points to the last line of this code in the /yiisoft/yii2-mongodb/Command.php file:
$this->document = $this->db->getQueryBuilder()->aggregate($collectionName, $pipelines, $options);
        $cursor = $this->execute();

        $result = current($cursor->toArray());

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question