<?php
//---[ simpleObjectDB ]---
// demo-step-5 "change"
//
// change fields of object person1 and
// save object's state back to persistence system
// ps: you can run this script repeatable ;)
//
$include_root = '../include/';
require_once( $include_root . 'functions/ClassLoader.php' );
load_class( 'PersistenceSystem/PersistenceSystem.php' );
$initParams = array();
$initParams["storageRoot"] = 'root2/';
$oid = 'root:person1';
// initialize
$persistenceSystem = new PersistenceSystem( $initParams );
// get object
$object1 = $persistenceSystem->getObject( $oid );
// show fields
print "field 'name': [". $object1->getField('name') ."]\n";
print "field 'IQ': [". $object1->getField('IQ') ."]\n";
// change fields
$object1->setField( 'name', 'ilya' );
$object1->setField( 'IQ', $object1->getField('IQ') + 1 );
// save object
$object1->save();
// get object again
$object2 = $persistenceSystem->getObject( $oid );
// show fields
print "after changes:\n";
print "field 'name': [". $object2->getField('name') ."]\n";
print "field 'IQ': [". $object2->getField('IQ') ."]\n";
print "salary: [". $object2->getSalary() ."]\n";
?>
|