Bouncy Melons 0.2
declarative style orm
namespace bm\example;
* sometimes we do not need any specific behaviour from singles and lists,
* for example - if we want to create just one more view.
* in this example we will create veiw where WineBottles will be grouped
* by brand and we will count how much WineBottles of each brand we have
* this style will save you some time on simple views, but it won't allow you to
* modify default behaviour of \bm\DataList and \bm\Single, and you won't be able
* to extends \bm\Single with new methods, so
* it's not recommended for working with important data.
class VCountWineBottles extends \bm\VModel {
* same declaration as in \bm\Single children
public function declareFields() {
return [
new \bm\IdField('brand', 'Brand',['list'=>VBrands::getSlug()]),
new \bm\NumericField('count','Count')
* this is report, based on different tables, so we will mark it as not editable
public function isEditable() {
return false;
* same as in \bm\DataList children
public function declareView() {
$brands = new Brands();
$bottles = new WineBottles();
tBrands.title, COUNT( AS `count`
`".$brands->getTableName()."` AS tBrands
`".$bottles->getViewName()."` AS tBottles ON (
tBottles.brand =