MongoDataSource

Introduction #

MongoDataSource helps you to connect to MongoDB to retrieve data. You need to install the MongoDB package.

Settings #

Nametypedefaultdescription
classstringMust set to '\koolreport\datasources\MongoDataSource'
connectionStringstringDefine connection string to MongoDB. If you use connectionString, you do not need to set properties host, username and password.
hoststringMongoDB host
usernamestringUsername
passwordstringPassword
databasestringThe name of database you want to connect

Example #

<?php
class MyReport extends \koolreport\KoolReport
{
    public function settings()
    {
        return array(
            "dataSources"=>array(
                "mongo_purchase"=>array(
                    "class"=>'\koolreport\mongodb\MongoDataSource',
                    "connectionString"=>"mongo://johndoe:secret_password@localhost:65432",
                    "database"=>"dbpurchase"
                ),
            )
        );
    }
    public function setup()
    {
        $this->src('mongo_purchase')
        ->query(array("colection"=>"cPurchases"))
        ->pipe(..)
        ->pipe(...)
        ...
        ->pipe($this->dataStore('mongo_purchases'));
    }
}