Bouncy Melons 0.1
declarative style orm
single.php
Go to the documentation of this file.
1 <?php
2 namespace bm\example;
3 /*
4  * let's declare WineBottle class which will represent
5  * single bottle of wine
6  */
7 class WineBottle extends \bm\Single {
8 
9  /*
10  * this method overrides bm\Single::declareFields abstract method
11  */
12  public function declareFields() {
13  return [
14  /*
15  * basic string field with default options
16  */
17  new \bm\StringFiled('title','Title'),
18 
19  /*
20  * string field with options and type that should be used in sql table declaration
21  */
22  new \bm\TextField('description', 'Short description', [
23  'tip'=>'short text limited to 255 symbols'
24  ], 'VARCHAR(255)'),
25 
26  /*
27  * numeric field, to display price like "100.00 eur"
28  */
29  new \bm\NumericField('price','Price',['decimals'=>2,'suffix'=>'eur']),
30 
31  /*
32  * one-to-many connection
33  */
34  new \bm\IdField('brand','Brand',['list'=>VBrands::getSlug()]),
35 
36  /*
37  * your own field type, should implement bm\IField
38  * this one has option clac = true this field value will be calculated
39  * by custom sql code, see list.php
40  */
41  new MyFieldType('random','Random Number',['field'=>'specific options','calc'=>true], 'BLOB'),
42  ];
43  }
44 }