MongoLite\Database::__construct PHP Метод

__construct() публичный Метод

Constructor
public __construct ( string $path = ":memory:", array $options = [] )
$path string
$options array
    public function __construct($path = ":memory:", $options = array())
    {
        $dns = "sqlite:{$path}";
        $this->path = $path;
        $this->connection = new \PDO($dns, null, null, $options);
        $database = $this;
        $this->connection->sqliteCreateFunction('document_key', function ($key, $document) {
            $document = json_decode($document, true);
            $val = '';
            if (strpos($key, '.') !== false) {
                $keys = explode('.', $key);
                switch (count($keys)) {
                    case 2:
                        $val = isset($document[$keys[0]][$keys[1]]) ? $document[$keys[0]][$keys[1]] : '';
                        break;
                    case 3:
                        $val = isset($document[$keys[0]][$keys[1]][$keys[2]]) ? $document[$keys[0]][$keys[1]][$keys[2]] : '';
                        break;
                    default:
                        $val = isset($document[$keys[0]]) ? $document[$keys[0]] : '';
                }
            } else {
                $val = isset($document[$key]) ? $document[$key] : '';
            }
            return is_array($val) || is_object($val) ? json_encode($val) : $val;
        }, 2);
        $this->connection->sqliteCreateFunction('document_criteria', function ($funcid, $document) use($database) {
            $document = json_decode($document, true);
            return $database->callCriteriaFunction($funcid, $document);
        }, 2);
        $this->connection->exec('PRAGMA journal_mode = MEMORY');
        $this->connection->exec('PRAGMA synchronous = OFF');
        $this->connection->exec('PRAGMA PAGE_SIZE = 4096');
    }