Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $this->Project->contain();
- $this->Project->virtualFields['completion'] = '
- ROUND(
- ((SUM(Todo.complete) + SUM(TodoExtra.complete)) /
- (COUNT(Todo.complete) + COUNT(TodoExtra.complete))) *
- 100
- )
- ';
- $projects = $this->Project->find('all', array(
- 'joins' => array(
- array(
- 'alias' => 'Todo',
- 'table' => 'project_todos',
- 'type' => 'LEFT',
- 'conditions' => array(
- '`Todo`.`project_id` = `Project`.`id`',
- ),
- ),
- array(
- 'alias' => 'TodoExtra',
- 'table' => 'project_todo_extras',
- 'type' => 'LEFT',
- 'conditions' => array(
- '`TodoExtra`.`project_id` = `Project`.`id`',
- ),
- )
- ),
- 'group' => array(
- 'Project.id',
- ),
- ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement