edoceo

Radix PHP DB Mongo


<?php
/**
    @file
    @brief Mongo DB Integration Example
*/

$arg = array(
    'hostname' => 'mongodb://localhost:27017',
    'database' => 'somedb',
    'username' => 'someun',
    'password' => 'somepw',
);

// Init the Static Class
radix_db_mongo::init($arg);

// Uses defaults set above
$mdb = new radix_db_mongo();

// Use specific settings
$arg['database'] = 'nextdb';
$mdb1 = new radix_db_mongo($arg);

// This is an Atomic Update Operation
$res = $mdb->execute("return db.service.findAndModify({
    query  : { 
        check_next: { \$lte: {$_SERVER['REQUEST_TIME']} },
        check_command: { \$ne: '' }
    },
    sort   : { check_next: 1 },
    update : { \$inc : { check_exec:1, check_next: 240 } }
})");

Loading Comments from Disqus...