PHP code example of mofing / mongodb

1. Go to this page and download the library: Download mofing/mongodb library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mofing / mongodb example snippets


Plugin::load('Mofing/Mongodb');


 'Datasources' => [
    'default' => [
        'className' => 'Mofing\Mongodb\Database\Connection',
        'driver' => 'Mofing\Mongodb\Database\Driver\Mongodb',
        'persistent' => false,
        'host' => 'localhost',
        'port' => 27017,
        'login' => '',
        'password' => '',
        'database' => 'devmongo',
        'ssh_host' => '',
        'ssh_port' => 22,
        'ssh_user' => '',
        'ssh_password' => '',
        'ssh_pubkey_path' => '',
        'ssh_privatekey_path' => '',
        'ssh_pubkey_passphrase' => ''
    ],
],

//src/Model/Table/YourTable.php

use Mofing\Mongodb\ORM\Table;

class CategoriesTable extends Table {

}

$this->Categories->find('all', ['conditions' => ['name' => 'teste']]);
$this->Categories->find('all', ['conditions' => ['name LIKE' => 'teste']]);
$this->Categories->find('all', ['conditions' => ['name' => 'teste'], 'limit' => 3]);

$this->Categories->find('all', ['conditions' => [
    '_id' => new \MongoDB\BSON\ObjectId('5a7861909db0b47d605c3865'),
    'foo.bar' => new \MongoDB\BSON\Regex('^(foo|bar)?baz$', 'i')
]]);
ssh_user