PHP Classes

File: examples/testreduce.php

Recommend this page to a friend!
  Classes of Jorge Castro   PHP Document Store One   examples/testreduce.php   Download  
File: examples/testreduce.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Document Store One
Store and retrieve key-value pairs in flat files
Author: By
Last change:
Date: 3 years ago
Size: 824 bytes


Class file image Download

use eftec\DocumentStoreOne\DocumentStoreOne;


try {
$ds = new DocumentStoreOne('base', 'purchases');
} catch (
Exception $e) {

$products=$ds->collection('products')->get('listproducts'); // if the list of products is limited then, we could store the whole list in a single document.
$purchases=$ds->collection('purchases')->select(); // they are keys such as 14,15...


$purchases as $k) {
$purchase=unserialize( $ds->get($k));
$customerXPurchase[$purchase->customer]+=($purchase->amount * @$products[$purchase->productpurchase]); // we add the amount

$ds->collection('total')->insertOrUpdate(serialize($customerXPurchase),'customerXPurchase'); // we store the result.