PHP Classes

PHP JSON DB Class: Manipulate JSON data as database tables

Recommend this page to a friend!
  Info   View files Example   Demos   View files View files (19)   DownloadInstall with Composer Download .zip   Reputation   Support forum (4)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 66%Total: 262 All time: 7,787 This week: 455Up
Version License PHP version Categories
json-db-class 0.1.4GNU General Publi...5.4PHP 5, Databases, Files and Folders
Description 

Author

This package can manipulate JSON data as database tables.

The package provides a base model class that should be extended by implementation model classes to define the class properties like their names, types, default values and descriptions.

Once extended from the base class, model class objects can perform common operations to create, retrieve, update and delete objects to be stored in files in the JSON format.

The model classes can also validate objects, search for objects and returned the results sorted according to a given criteria.

Picture of Maicon gonšalez
  Performance   Level  
Name: Maicon gonšalez <contact>
Classes: 5 packages by
Country: Brazil Brazil
Age: 30
All time rank: 2470171 in Brazil Brazil
Week rank: 262 Up22 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 3x

Example

<?php
###########################
########_Setup.php#########
###########################
###########################

// Inclue o Arquivo
require_once("../JsonDb/JsonDbJdb.php");
//Define o diretorio para os modelos
JsonDb_Core::getInstance()->setDir("../JsonDb/ModelJdb/");

###########################
####GenerateModel.php######
###########################
###########################
# View Full Documentation On http://jsondb.inclouds.com.br/index.php/Page/jsondb-gerar-modelos

/**
*
* JsonDb_Create Class to create model
* @Arg Name of Model
*/
$Create = new JsonDb_Create("Users");

/**
*
* @method setColun Define the columns of your document
* @Args
* $Name - Name of Column,
* $type - Type Data,
* $default - Default value if not set to save or set a Array for single or multiple options
* $description - Column Description
* $Create->setColun($name,$type,$sizeVal = null,$default = null,$description = null);
*/
$Create->setColun('Nome','varchar',20);
$Create->setColun('Sobrenome','varchar',20);
$Create->setColun('Nascimento','date');
$Create->setColun('Sexo','singleOption',array("--","f","m"),"--");
$Create->setColun('Email','varchar',50);
$Create->setColun('Password','varchar',50);

/*
* @method setMany Define the relational model
* @Args
* $model - Name relational Model,
* $key1 - Column of the Current Model,
* $key2 - Column of the Relational Model
* $Create->setMany($model,$key1,$key2);
*/
$Create->setMany("Adress","_Id","UserId");

//Save Model
$Create->save();

//Create Relational Model
$Create = new JsonDb_Create("Adress");
$Create->setColun('Adress','varchar');
$Create->setColun('City','varchar');
$Create->setColun('State','varchar');
$Create->setColun('Country',"varchar");
$Create->setColun('ZipCode','varchar');
$Create->setColun('UserId','varchar');
$Create->save();



###############################################
##############WorkData.php#####################
###############################################

//After creating your model, you can insert, read, update, and remove data
//Model User Generate On File "GenerateModel.php"

# View Full Documentation On http://jsondb.inclouds.com.br/

# Insert Data - http://jsondb.inclouds.com.br/index.php/Page/inserir-dados
# Validation Values - http://jsondb.inclouds.com.br/index.php/Page/validacao
# Search Data - http://jsondb.inclouds.com.br/index.php/Page/buscar-dados
# Order Data - http://jsondb.inclouds.com.br/index.php/Page/ordenar-dados
# Update Data - http://jsondb.inclouds.com.br/index.php/Page/alterar-dados
# Remove Data - http://jsondb.inclouds.com.br/index.php/Page/remover-dados
# Others - http://jsondb.inclouds.com.br/index.php/Page/outras-funcoes

//Insert New Data
   
$User = new ModelJdb_Users();
   
$User->Nome = "Felipe";
   
$User->Sobrenome = "Smith";
   
$User->Nascimento = "18/10/1995";
   
$User->Sexo = "m";
   
$User->Email = "felipesmith@exemplo.com.br";
   
$User->Password = sha1("123456");
   
$User->save();
   
   
// Check Errors
   
$Errors = $User->getErrors();
    if (
is_array($Errors)){
       
print_r($Errors);
    }

//Inser New Data With Relative Model
   
$User = new ModelJdb_Users();
   
$User->getRelative("Adress");

   
$User->Nome = "Felipe";
   
$User->Sobrenome = "Smith";
   
$User->Nascimento = "18/10/1995";
   
$User->Sexo = "m";
   
$User->Email = "felipesmith@exemplo.com.br";
   
$User->Password = sha1("123456");
       
$User->_Adress['Adress'] = "16?18?";
       
$User->_Adress['City'] = "QD 34 LT 10";
       
$User->_Adress['State'] = "Seu Pai";
       
$User->_Adress['Country'] = "Meu Brašo";
       
$User->_Adress['ZipCode'] = "Quebrou";
   
$User->save();
   
//Inser New Data With Relative Model (Many Data)
   
$User = new ModelJdb_Users();
   
$User->getRelative("Adress");

   
$User->Nome = "Felipe";
   
$User->Sobrenome = "Smith";
   
$User->Nascimento = "18/10/1995";
   
$User->Sexo = "m";
   
$User->Email = "felipesmith@exemplo.com.br";
   
$User->Password = sha1("123456");
       
$User->_Adress[0]['Adress'] = "16?18?";
       
$User->_Adress[0]['City'] = "QD 34 LT 10";
       
$User->_Adress[0]['State'] = "Seu Pai";
       
$User->_Adress[0]['Country'] = "Meu Brašo";
       
$User->_Adress[0]['ZipCode'] = "Quebrou";
       
$User->_Adress[1]['Adress'] = "16?18?";
       
$User->_Adress[1]['City'] = "QD 34 LT 10";
       
$User->_Adress[1]['State'] = "Seu Pai";
       
$User->_Adress[1]['Country'] = "Meu Brašo";
       
$User->_Adress[1]['ZipCode'] = "Quebrou";
   
$User->save();
   
//Update Data
   
$Model = new ModelJdb_Users();
   
$Model->findOneByNome("Felipe");
   
$Model->Nome = "Felipe Da Silva";
   
$Model->save();
   
//Remove Data
   
$Model = new ModelJdb_Users();
   
$Model->findOneByNome("Felipe");
    if (
$Model instanceof ModelJdb_Users){
       
$Model->remove(false);
    }

//FindBy
$User = new ModelJdb_Users();
$User->getRelative("Adress");
$Data = $User->findByNome("Felipe")->toArray();
echo
"<pre>";
print_r($Data);
echo
"</pre>";


//http://jsondb.inclouds.com.br/index.php/Page/exportar-para-cvs

//////////////////////Export All

//$User = new ModelJdb_Users();

/**
* $Delimiter is Optional
* Ex: $User->getCvs(";");
* Ex: $User->getCvs(",");
*/

//$User->getCvs();

//////////////////////Export Results

//$User = new ModelJdb_Users();
//$User->findByNome("Felipe");

/**
* $Delimiter is Optional
* Ex: $User->getCvs(";");
* Ex: $User->getCvs(",");
*/

//$User->getCvs();


Details


  Files folder image Files  
File Role Description
Files folder imageExemplo (7 files)
Files folder imageJsonDb (10 files, 1 directory)
Accessible without login Plain text file README.md Data Auxiliary data

  Files folder image Files  /  Exemplo  
File Role Description
  Accessible without login Plain text file AllThis.php Example Example script
  Accessible without login Plain text file ExportCvs.php Example CVS Export
  Accessible without login Plain text file FindBy.php Example New Example
  Accessible without login Plain text file GenerateModel.php Example Example script
  Accessible without login Plain text file WorkData.php Example Example script
  Accessible without login Plain text file WorkRelative.php Example New Example
  Accessible without login Plain text file _Setup.php Example Example script

  Files folder image Files  /  JsonDb  
File Role Description
Files folder imageModelJdb (1 file)
  Accessible without login Plain text file baseModel.txt Doc. Documentation
  Plain text file Core.php Class Class source
  Plain text file Create.php Class Class source
  Plain text file Functions.php Class Class source
  Plain text file Json.php Class Class source
  Plain text file JsonCvs.php Class CVS Export
  Plain text file JsonDbJdb.php Class Class source
  Plain text file JsonSets.php Class Class source
  Plain text file Property.php Class Class source
  Plain text file stdObject.php Class Class source

  Files folder image Files  /  JsonDb  /  ModelJdb  
File Role Description
  Accessible without login Plain text file .htaccess Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:262
This week:0
All time:7,787
This week:455Up
User Ratings User Comments (1)
 All time
Utility:91%StarStarStarStarStar
Consistency:75%StarStarStarStar
Documentation:58%StarStarStar
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:66%StarStarStarStar
Rank:520