PHP Classes

Object Manager: Store and retrieve objects in MySQL table records

Recommend this page to a friend!
  Info   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2008-03-11 (8 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 378 This week: 2All time: 6,382 This week: 611Up
Version License PHP version Categories
objectmanager 1.1GNU General Publi...5.0PHP 5, Databases
Description Author

This class can be used to store and retrieve objects in MySQL table records.

It serializes and unserializes objects to store and retrieve it in a given table. It can also query, update and delete an object given the identifier used to store it in the MySQL table.

The class can also create the necessary tables to store objects of different classes.

Picture of David Johns
Name: David Johns <contact>
Classes: 2 packages by
Country: United Kingdom United Kingdom
Age: 53
All time rank: 207491 in United Kingdom United Kingdom
Week rank: 554 Up15 in United Kingdom United Kingdom Up

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.


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. 


To update that object

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


To delete an object.






Order by surname Ascending

Order by surname Descending

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();


To get ordered results, the correct order must be followed

Set order
Get results

Please see for updates and further examples.

To report bugs please use
To contact me (David Johns)  or become part of this project please use

  Files folder image Files  
File Role Description
Plain text file objectManager.class.php Class main class
Accessible without login Plain text file readme.txt Doc. Basic examples and implementation for Version 2

 Version Control Unique User Downloads Download Rankings  
This week:2
All time:6,382
This week:611Up