PHP Classes
elePHPant
Icontem

File: examples/foreach.php

Recommend this page to a friend!
  Classes of Rafa Rodriguez  >  Div PHP Nodes  >  examples/foreach.php  >  Download  
File: examples/foreach.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Div PHP Nodes
Manage database of objects stored in record files
Author: By
Last change:
Date: 2 years ago
Size: 680 bytes
 

 

Contents

Class file image Download
<?php

/**
 * Div PHP Nodes
 *
 * Example
 *
 * @author Rafa Rodriguez [@rafageist] <rafageist@hotmail.com>
 */
include "../divNodes.php";

// Adding a schema on the fly if not exists
$db = new divNodes("database/contacts");

// Iterate each node with age < 20
$db->forEachNode(function(&$contact, $id, $schema, $db){

    if (
$contact['age'] < 20)
        return
DIV_NODES_FOR_CONTINUE_DISCARDING;

    if ( ! isset(
$contact['visitors']))
       
$contact['visitors'] = 0;

   
$contact['visitors']++;

    echo
"Name: {$contact['name']} <br/>\n";
    echo
"Phone: {$contact['phone']} <br/>\n";
    echo
"Email: {$contact['email']} <br/>\n";
    echo
"Visitors: {$contact['visitors']} <br/>\n";
    echo
"\n";
});