PHP Classes

PHP MongoDB Mini ODM: Store and retrieve objects in MongoDB databases

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 58%Total: 366 All time: 6,851 This week: 455Up
Version License PHP version Categories
mongodb-mini-odm 1.0GNU General Publi...5.2PHP 5, Databases, Design Patterns
Description 

Author

This package can be used to store and retrieve objects in MongoDB databases.

The main class can load model classes of objects from a given directory, so the objects can be used to store and retrieve information from a given MongoDB database records.

The model objects extend the base MongoDB table class so they define the properties, relationships and indexes of the database records that will be mapped to objects the the model classes.

The model classes can perform operations like saving an object, finding objects by a given criteria and remove objects from the database.

Innovation Award
PHP Programming Innovation award nominee
January 2015
Number 3


Prize: PhpStorm IDE personal permanent license
Nowadays many PHP applications are totally object oriented. This means that they treat practically all application entities as objects.

For applications that use relational databases, it is common to implement a layer of mapping between application objects and database records often called ORM (Object-Relational Mapping), so the application can treat information in the database as objects.

MongoDB is not really a relational database. It is rather document based database.

This package implements a concept similar to object-relational mapping but for documents stored in a MongoDB database. So it provides an interface to store and retrieve application objects from MongoDB documents.

Manuel Lemos
Picture of Maicon gonçalez
  Performance   Level  
Innovation award
Innovation award
Nominee: 3x

 

Example

<?php
   
require_once("Mongo/Mongo.php");
   
$User = new Model_Users();
   
//Use Parent
   
$User->Parent = 1; // 1: true 0:false
   
    //Defined Coluns
   
$User->Nome = "Ex Of Name";
   
$User->Email = "test@gmail.com";
   
$User->User = "James";
   
$User->Senha = sha1('123456');
   
$User->Clube = json_encode(array("Chelsea","Man. City","Barcelona"));
   
$User->Cpf = "980.098.827-20";
   
   
// News Coluns
   
$User->Macaca = "";
   
   
//Parent Model
   
$User->_Andress = array();
   
$User->_Andress['Rua'] = "Rua da Couves";
   
$User->_Andress['Bairro'] = "Pq. Esplanada";
   
$User->_Andress['Cidade'] = "Valparaiso";
   
$User->_Andress["Estado"] = "GO";
   
   
//Salvar
   
$User->save();
   
   
// Find All
   
$Find = $User->find();
    echo
"<pre>";
   
print_r($Find);
    echo
"</pre>";
   
   
/*$Find = $User->find(
        Codition,
        limit,
        skip,
        sort
    );*/
   
    // Find One
   
$Find = $User->findOneByNome("Ex Of Name");
    echo
"<pre>";
   
print_r($Find);
    echo
"</pre>";
   
   
// Find All By
   
$Find = $User->findByNome("Ex Of Name");
    echo
"<pre>";
   
print_r($Find);
    echo
"</pre>";
   
   
//Update Data (findByNome("Ex Of Name"))
   
$User->Nome = "Update Name";
   
$User->save();
   
   
/*$Find = $User->findOneBy 'NameofColun' (
        Value,
        limit,
        skip,
        sort
    );*/
   
   
?>


  Files folder image Files (18)  
File Role Description
Files folder imageGenerator (1 file, 3 directories)
Files folder imageModels (2 files)
Files folder imageMongo (1 file, 1 directory)
Accessible without login Plain text file Teste.php Example Example

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:366
This week:0
All time:6,851
This week:455Up
 User Ratings  
 
 All time
Utility:83%StarStarStarStarStar
Consistency:83%StarStarStarStarStar
Documentation:-
Examples:83%StarStarStarStarStar
Tests:-
Videos:-
Overall:58%StarStarStar
Rank:1495