Recommend this page to a friend! |
Download .zip |
Info | View files (16) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2009-04-13 (7 years ago) | Not enough user ratings | Total: 234 | All time: 7,535 This week: 916 |
Version | License | PHP version | Categories | |||
struct 0.1 | GNU General Publi... | 5.0 | XML, PHP 5, Databases, Data types |
There are some attempts to build type safe php objects, but they all have lacks on working with eaccelarator, when they check against phpdoc comments as type safety validation notation. E.g. POPO (plain old php objects) from http://jan.kneschke.de/projects/typesafe-objects-in-php validates against the doc comment of the reflected object. But when the object is bytecoded by eAccelarator all comments are removed from the source. Means: "type safe" properties loose their information and the object does not work any more. This class set is an attempt to fix this lack. Look at the sample (auto-generated db model struct class file) and see how it works. All object properties have their own dynamic getters and setters. So, if you have a db column named caption, then you can set a value by simply writing (when the object is instantiated): $o->setCaption("my value"). Properties of a model class do only need a type prefix in front of the property name. Supported type prefixes for now: - string (varchar, char, text, etc.) - float (real,decimal,float) - integer (int,smallint,bigint,etc.) - bool (tinyint,bool) - array (enum) How do I insert a value? Valid setValue sample: $clsObject = new Model_Objects_Countries; $clsObject->setContinent("Asia"); Invalid setValue sample: $clsObject = new Model_Objects_Countries; $clsObject->setContinent(true); If you try to set an invalid value then an exception will thrown How do I get a value? $clsObject = new Model_Objects_Countries; $clsObject->getContinent(); Once an object is filled, you can use the SerializeTypeStruct class to convert your object into different output formats. SerializeTypeStruct provides only two formats for giving you an image of what can be done. You can implement any kind of output format (CSV, PDF, XLS and so on), but you have to write it on your own. Regards Tom |
Files |
File | Role | Description | ||
---|---|---|---|---|
ver0.2 (10 files) | ||||
TypedStruct.class.php | Class | Base class | ||
SerializeTypedStruct.class.php | Class | Sample Base class extension => serializes an object's properties | ||
TypeSafeStruct.class.php | Class | Base class extension | ||
sample.php | Example | as the name says | ||
baseobject_country.php | Example | persistent type safe model object operating with mysql sample world db | ||
readme.txt | Doc. | readme |
Files | / | ver0.2 |
File | Role | Description |
---|---|---|
sample.php | Example | sample console script running sql select |
sampledate.php | Example | Working with timestamps |
TBit.class.php | Class | ValueType Object |
TEnum.class.php | Class | ValueType Object |
TLob.class.php | Class | ValueType Object |
TNumber.class.php | Class | ValueType Object |
TString.class.php | Class | ValueType Object |
TTimestamp.class.php | Class | ValueType Object |
TypedStruct.class.php | Class | Typed Struct |
TypeSafeStruct.class.php | Class | Type Safe Struct |
struct-2009-04-13.zip 16KB | |
struct-2009-04-13.tar.gz 11KB | |
Install with Composer |
Needed packages | ||
Class | Download | Why it is needed | Dependency |
---|---|---|---|
TString | .zip .tar.gz | since v0.2 TSS will support ValueType Objects. TString is the first kind of value type. | Optional |
TNumber | .zip .tar.gz | Value Type Object | Optional |
TBit | .zip .tar.gz | ValueTypeObject | Optional |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
0% |
|
|