Recommend this page to a friend! |
Download .zip |
Info | View files (2) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2008-03-11 (8 years ago) | Not yet rated by the users | Total: 378 This week: 1 | All time: 6,384 This week: 1,047 |
Version | License | PHP version | Categories | |||
objectmanager 1.1 | GNU General Publi... | 5.0 | PHP 5, Databases |
Description | Author | |||||||||||||
This class can be used to store and retrieve objects in MySQL table records. |
|
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 |
Files |
File | Role | Description |
---|---|---|
objectManager.class.php | Class | main class |
readme.txt | Doc. | Basic examples and implementation for Version 2 |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
0% |
|
|
Applications that use this package |
phpobject.org Home page for class. Full function list and example script |
If you know an application of this package, send a message to the author to add a link here.