Created
July 9, 2011 19:51
-
-
Save abbajbryant/1073889 to your computer and use it in GitHub Desktop.
virtualField count example for Dominik Gajewski
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class DepartmentBook extends AppModel | |
{ | |
public $name = "DepartmentBook"; | |
public $virtualFields = array( | |
'kl' => 'count(*)', | |
); | |
} | |
?> | |
<?php | |
class DepartmentsController extends AppController | |
{ | |
public $name "Departments"; | |
public function index( ){ | |
debug( $this->DepartmentBook->find( 'all', array( | |
'fields' => array( 'DepartmentBook.kl', 'DepartmentBook.department_id' ), | |
'conditions' => array( 'DepartmentBook.extract_date' => null ), | |
'order' => array( 'DepartmentBook.department_id' ), | |
'group' => array( 'DepartmentBook.department_id' ), | |
))); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment