Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Table: Employee
- | id | name | position |
- | 1 | Ned | kitchen |
- | 2 | Bob | server |
- | 3 | Jon | server |
- Table: Tips
- | id | employee | date | amount
- | 1 | 1 | 2012-11-12 | 9.00
- | 2 | 2 | 2012-11-14 | 4.55
- | 3 | 1 | 2012-11-15 | 8.01
- | 4 | 2 | 2012-11-15 | 2.00
- | 5 | 1 | 2012-11-23 | 3.02
- ------------------------------------
- Example code
- ------------------------------------
- $sdate = '2012-11-01';
- $edate = '2012-11-31';
- $entries = Model_Employee::find('all', array(
- 'related' => array(
- 'tips' => array(
- 'join_type' => 'left',
- 'where' => array(
- array('date', '>=', $sdate),
- array('date', '<=', $edate),
- ),
- ),
- )
- ));
- ------------------------------------
- Expected result:
- Ned
- position => kitchen
- tips =>
- 9.00
- 8.01
- 3.02
- Bob
- position => server
- tips =>
- 4.55
- 2.00
- Jon
- position => server
- tips =>
- ------------------------------------
- Actual result:
- Ned
- position => kitchen
- tips =>
- 9.00
- 8.01
- 3.02
- Bob
- position => server
- tips =>
- 4.55
- 2.00
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement