PHP Classes

File: src/BigExample/demo.php

Recommend this page to a friend!
  Classes of Joseluis Laso  >  Simple PHP Memory Database  >  src/BigExample/demo.php  >  Download  
File: src/BigExample/demo.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Simple PHP Memory Database
Manipulate databases stored in JSON format files
Author: By
Last change: fixing CS & MD
Date: 5 years ago
Size: 1,029 bytes


Class file image Download

namespace JLaso\SimpleMemoryDb\BigExample;



/** @var RepositoryInterface[] $databases */
$databases = [];

$databases['customers'] = new CustomerTable(__DIR__.'/customers.json');
$databases['taxes'] = new TaxTable(__DIR__.'/taxes.json');
$databases['countries'] = new CountryTable(__DIR__.'/countries.json');

$countryId = 1 + rand(0, count($databases['countries']->findAll()));
$country = $databases['countries']->find($countryId);

printf("Showing results for country %s ...\r\n", $country['name']);
foreach (
$databases['customers']->findAll('country_id', $countryId) as $customer) {
$tax = $databases['taxes']->find($customer['tax_type_id']);

"Customer (%d) %s applies %s '%s' [%.2f%%]\r\n",

printf("There are %d customers\r\n", $databases['customers']->count());

For more information send a message to info at phpclasses dot org.