PHP Classes

XMongoDB : Build and execute queries to a MongoDB database

Recommend this page to a friend!
  Info   View files Example   View files View files (15)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 155 All time: 9,007 This week: 110Up
Version License PHP version Categories
xmongodb 1.14MIT/X Consortium ...5.4PHP 5, Databases
Description 

Author

This package can build and execute queries to a MongoDB database.

It can compose queries to retrieve, insert, update and delete documents using a fluent interface to define several parameters of the queries.

It can also create a database and document indexes.

The parameters define values like the collections of documents to be accessed, conditions on the fields of the documents to match, order and range of the documents to retrieve, etc..

Picture of Xavier Pérez
  Performance   Level  
Name: Xavier Pérez <contact>
Classes: 9 packages by
Country: Spain Spain
Innovation award
Innovation award
Nominee: 1x

Recommendations

What is the best PHP mongodb class?
Need a simple framework that wraps the low level mongodb

What is the best PHP mongodb class?
Perform all kinds of actions with MongoDB

Example

<?php

namespace XMongoDB\Examples;

use
XMongoDB\lib\XMongoDB;
use
XMongoDB\lib\XMongoDBConfig;

header('Content-Type: text/html; charset=utf-8');
error_reporting(E_ALL & ~E_STRICT);
ini_set('display_errors', true);

require
__DIR__."/../lib/XMongoDBDriver.php";
require
__DIR__."/../lib/XMongoDBComm.php";
require
__DIR__."/../lib/XMongoDBCursor.php";
require
__DIR__."/../lib/XMongoDB.php";
require
__DIR__."/../lib/XMongoDBConfig.php";

echo
"<h1>Remember to load examples (/xmongodb/examples/exportExamples.js) in your mongodb instance</h1>";

class
test
{
    protected
$xmongoconfig;
    protected
$xmongodb;
       
    public function
__construct()
    {
       
// Set MongoConfig
       
$this->xmongoconfig = new XMongoDBConfig('localhost',27017,'mydb','','',true);

       
// Load Mongo connection
       
$this->xmongodb = new XMongoDB($this->xmongoconfig);
       
// Set debug mode
       
$this->xmongodb->debug = true;
       
    }
   
    public function
test1()
    {
       
// SELECT * FROM collection WHERE awards.year = 2001
       
$result = $this->xmongodb->where(array('awards.year' => 2001))->get('collection');

       
// Show results & debug
       
echo "<h2>RESULTS for award->year == 2001 </h2>";
        echo
"Found ".$result->num_rows()." records of a total of ".$result->total_rows()."<br />";
       
var_dump($result->result());
       
        echo
"<h2>DEBUG</h2>";
       
var_dump($this->xmongodb->getDebug());
        echo
"<hr>";

    }
   
    public function
test2()
    {
       
// Clear debug, if not, debug adds every query to the main debug array
       
$this->xmongodb->clearDebug();

       
// SELECT DISTINCT name.first FROM collection
       
$result = $this->xmongodb->like('name.first','john')
                    ->
distinct('collection','name');


       
// Show results & debug
       
echo "<h2>RESULTS for DISTINCT name.first like 'john'</h2>";
       
var_dump($result);
       
        echo
"<h2>DEBUG</h2>";
       
var_dump($this->xmongodb->getDebug());
    }
}

$test = new test();

$test->test1();
$test->test2();


Details

XMongoDB

A PHP ORM library to handle opperations with MongoDB

* Select, Distinct, Where, OrderBy, Limit, Offset, Insert, Update, Delete, Create, Pop, Pull, Push, Aggregate, Indexes, Commands, AddtoSet, Inc, Dec

* All commands like ORM, example:

    $result = $XMongodDB->->where(array('email' => 'email@myemail.com))->get('customers');

* Where:

* Between
* Greater than
* Lower than
* Greater or equal than
* Lower or equal than
* Not equal
* Equal
* Near
* Like
* Not Like
* All can be mixed with AND/OR

* OrderBy ASC / DESC

* Limit and Offset

Getting Started Guide

* Chapter 1 - Installation

* Chapter 2 - Basic select operations

* Chapter 3 - Advanced select operations

* Chapter 4 - Insert / Update / Delete

* Chapter 5 - Other operations

* Chapter 10 - Exceptions


  Files folder image Files  
File Role Description
Files folder imagedoc (6 files)
Files folder imageexamples (3 files)
Files folder imagelib (5 files)
Accessible without login Plain text file Readme.md Doc. Readme

  Files folder image Files  /  doc  
File Role Description
  Accessible without login Plain text file 1-installation.md Doc. Documentation
  Accessible without login Plain text file 10-exceptions.md Doc. Documentation
  Accessible without login Plain text file 2-basic-select-operations.md Doc. Documentation
  Accessible without login Plain text file 3-advanced-select-operations.md Doc. Documentation
  Accessible without login Plain text file 4-basic-iud-operations.md Data Auxiliary data
  Accessible without login Plain text file 5-other-operations.md Doc. Manual

  Files folder image Files  /  examples  
File Role Description
  Plain text file exportExample.csv Data Data
  Plain text file README.txt Doc. Readme
  Accessible without login Plain text file test.php Example Example script

  Files folder image Files  /  lib  
File Role Description
  Plain text file XMongoDB.php Class Class source
  Plain text file XMongoDBComm.php Class Class source
  Plain text file XMongoDBConfig.php Class Class source
  Plain text file XMongoDBCursor.php Class Class source
  Plain text file XMongoDBDriver.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:155
This week:0
All time:9,007
This week:110Up