Bouncy Melons 0.2
declarative style orm
single.php
<?php
namespace bm\example;
/*
* let's declare WineBottle class which will represent
* single bottle of wine
*/
class WineBottle extends \bm\Single {
/*
* this method overrides bm\Single::declareFields abstract method
*/
public function declareFields() {
return [
/*
* basic string field with default options
*/
new \bm\StringFiled('title','Title'),
/*
* string field with options and type that should be used in sql table declaration
*/
new \bm\TextField('description', 'Short description', [
'tip'=>'short text limited to 255 symbols'
], 'VARCHAR(255)'),
/*
* numeric field, to display price like "100.00 eur"
*/
new \bm\NumericField('price','Price',['decimals'=>2,'suffix'=>'eur']),
/*
* one-to-many connection
*/
new \bm\IdField('brand','Brand',['list'=>VBrands::getSlug()]),
/*
* your own field type, should implement bm\IField
* this one has option clac = true this field value will be calculated
* by custom sql code, see list.php
*/
new MyFieldType('random','Random Number',['field'=>'specific options','calc'=>true], 'BLOB'),
];
}
}