Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cirpo/557851 to your computer and use it in GitHub Desktop.
Save cirpo/557851 to your computer and use it in GitHub Desktop.
<?php
class OrdinativiMenuItemDayTable extends Doctrine_Table
{
public static function getInstance()
{
return Doctrine_Core::getTable('OrdinativiMenuItemDay');
}
public function getWeekMenus( $menu_id )
{
$foods = Doctrine::getTable('OrdinativiMenuItemDay')
->createQuery('a')
->leftJoin('a.MenuItemDays m')
->where('a.menu_id = ? ', $menu_id )
->execute();
foreach($foods as $food){
$weeks[$food->getWeek()][$food->getDay()] = $food;
}
return $weeks;
}
public function getCountWeekMenus( $menu_id )
{
return Doctrine::getTable('OrdinativiMenuItemDay')
->createQuery('a')
->where('a.menu_id = ? ', $menu_id )
->execute()->count();
}
}
OrdinativiMenuItem:
actAs: { Timestampable: ~ }
columns:
menu_id: { type: integer, notnull: true, default: 0 }
name: { type: string(255), notnull: true }
type: { type: string(3) }
state: { type: integer, notnull: true, default: 0 }
enabled: { type: boolean, notnull: true, default: 0 }
relations:
OrdinativiHealthState: { type: many, foreignType: one, class: OrdinativiHealthState, local: state, foreign: id, onDelete: CASCADE, foreignAlias: OrdinativiHealthStates }
OrdinativiMenu:
type: many
foreignType: one
class: OrdinativiMenus
local: menu_id
foreign: id
onDelete: CASCADE
foreignAlias: MenuItemDays
OrdinativiMenuItemDay:
actAs: { Timestampable: ~ }
columns:
menu_id: { type: integer, notnull: true, default: 0 }
item_id: { type: integer, notnull: true, default: 0 }
day: { type: integer(3), notnull: true, default: 0 }
week: { type: integer(3), notnull: true, default: 0 }
enabled: { type: boolean, notnull: true, default: 0 }
relations:
OrdinativiMenuItem:
type: many
foreignType: one
local: item_id
foreign: id
onDelete: CASCADE
foreignAlias: OrdinativiMenus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment