Skip to content

Instantly share code, notes, and snippets.

@abbajbryant
Created July 9, 2011 19:51
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 abbajbryant/1073889 to your computer and use it in GitHub Desktop.
Save abbajbryant/1073889 to your computer and use it in GitHub Desktop.
virtualField count example for Dominik Gajewski
<?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