PHP Classes
elePHPant
Icontem

File: examples/entities.php

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

 

Contents

Class file image Download
<?php

/**
/**
 * Div PHP Nodes
 *
 * Example
 *
 * @author Rafa Rodriguez [@rafageist] <rafageist@hotmail.com>
 */

include "../divNodes.php";

// Your entity
class Person {
    public
$first_name;
    public
$last_name;
    public function
getFullName() {
        return
$this->first_name . " " . $this->last_name;
    }
}

// Clear schema
$db = new divNodes ( 'database' );

$db->delNodes ();

$person = new Person ();
$person->first_name = "John";
$person->last_name = "Nash";

// Save entity
$db->addNode ( $person );

$person = new Person ();

$person->first_name = "Albert";
$person->last_name = "Einstein";

// Save entity
$db->addNode ( $person );

$entities = $db->getNodes ( array (
       
'order' => 'first_name'
) );

foreach (
$entities as $e ) {
    echo
$e->getFullName () . "<br/>\n";
}