File: simpleObjectDB2/example/step3-addObject.php

Recommend this page to a friend!
  Classes of Ilya Nemihin  >  simpleObjectDB  >  simpleObjectDB2/example/step3-addObject.php  >  Download  
File: simpleObjectDB2/example/step3-addObject.php
Role: Example script
Content type: text/plain
Description: step3-addObject
Class: simpleObjectDB
simple object database
Author: By
Last change:
Date: 17 years ago
Size: 864 bytes
 

Contents

Class file image Download
<?php

//---[ simpleObjectDB ]---
// demo-step-3 "addObject"
//
// add specific object (of Person class) to root object
//

$include_root = '../include/';
require_once(
$include_root . 'functions/ClassLoader.php' );

load_class( 'PersistenceSystem/PersistenceSystem.php' );
load_class( 'Objects/Person.php' );

$initParams = array();
$initParams["storageRoot"] = 'root2/';

$persistenceSystem = new PersistenceSystem( $initParams );

// get root object
$root = $persistenceSystem->getObject('root');

// create persistenable object of class Person
$person = new Person();
$person->setPersistenceMachinery( $persistenceSystem->persistenceMachinery );
$person->setId( 'person1' ); // oid will be 'root:person1'
$person->setField( 'name', 'ilya' );
$person->setField( 'IQ', 1 );

// add object to root
$root->addObject( $person );

?>


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