Login   Register  
PHP Classes
elePHPant
Icontem

File: readme.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of David Johns  >  Object Manager  >  readme.txt  >  Download  
File: readme.txt
Role: Documentation
Content type: text/plain
Description: Basic examples and implementation for Version 2
Class: Object Manager
Store and retrieve objects in MySQL table records
Author: By
Last change: Version 2, has simplified syntax, full querying and no longer uses a database to store objects
Date: 6 years ago
Size: 2,914 bytes
 

Contents

Class file image Download
objectManager.class v2.2

Not only does this class allow an object of another class, be stored it also allows updating, deleting and querying using SQL like syntax. The whole process has been simplified and streamlined since version 1.

Each class that requires persistence, must have a class variable $oid. This is a unique identifier for each object of that class. In order to query the object, class variables must be defined. Private and protected variables cannot be queried.

Each class is stored in its own file. The path to the directory where the file is stored must be set, and that directory must be made writable.

Improvements  since version 1.

1)	Does not use a database.
2)	Simplified syntax
3)	Full querying
4)	Results ordering
5)	Persistent classes are full portable


Read me.

Suggested location for your classes and objectManager.class is /classes. 
Suggested location for the storage files for your classes is /classes/data. This file must have its permission set to allow reading & writing to file.

The following examples use an item class.

For exampe $obMan= new objectManager("item","../classes/data/"); 

To save (insert)  an object.

$item=$obMan->insert($item);

To retrieve an object, where the id of the object is know

$id is the unique identifier for that class and must be an Integer. 

$item=$obMan->loadByID($id);

To update that object

$item->setName(‘edit this’);

$obMan->update($item);

To delete an object.

Either: 

$obMan->deleteByID($id);

Or

$obMan->delete($item);

Queries

Order by surname Ascending
$obMan->setOrder("surname",true); 

Order by surname Descending
$obMan->setOrder("surname",false); 

Select all *

$obMan->ORQuery("oid > 0");

Queries are split into AND or OR queries. Though it is hoped to improve the syntax in the future. Each element of the query must be separated by a space.

For instance.

$obMan->ANDQuery("oid > 100 firstname LIKE david  ");

SQL like keywords

= (equality)
> (Greater)
< (less)
<= (Less than equals) x <= y
>=(Greater than equals) y >= x
NOT= (not equality)

LIKE (similar to SQL LIKE but cannot use wildcard)

BEGIN (Word begins with character) $name BEGIN d //returns all the names that begin with d.

Please note that all statements are case sensitive. And that strings unlike SQL do not use ‘ string‘  to identify them.

Obtain results set.


$itemList=$obMan->getResults(); //always returns an array of ids.


foreach($itemList as $list){
$itemt = new item();
	
	
	
	$item=$obMan->loadByID($listl);

}


To get ordered results, the correct order must be followed

Set order
Query
Get results

Please see http://www.phpobject.org/ for updates and further examples.

To report bugs please use bugs@phpobject.org
To contact me (David Johns)  or become part of this project please use david@phpobject.org