SHARE
TWEET

Untitled

a guest Jun 27th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'fields' => array('Table.column', 'count(*) as virtualColumn'),
  2. 'group' => array('Table.column HAVING COUNT(*) >= 1'),
  3.      
  4. $conditions = ['TableA.AnyColumn'=> $id];
  5. $this->loadModel('TableA');
  6.  
  7. $this->TableA->belongsTo('TableB', [
  8.     'className' => 'TableB',
  9.     'propertyName' => 'table_b',
  10.     'foreignKey' => false,
  11.     'joinType' => 'LEFT',
  12.     'conditions' => ['TableB.any_column = TableA.any_column', 'TableB.some_other_column = TableA.some_other_column']
  13. ]);
  14.      
  15. $count = $this->TableA->find()->where($conditions)->group(['columnToBeGroupBy']);
  16. $count = $count->select(['columnToBeGroupBy', 'count' => $count->func()->count('TableA.columnToBeGroupBy')])->toArray();
  17.      
  18. $this->paginate = [
  19.     'contain' => ['TableC' => ['fields'=>['fields required']]],
  20.     'conditions' => $conditions,
  21.     'group' => 'TableA.columnToBeGroupBy',
  22.     'limit' => 20,
  23.     'order' => ['TableC.modified' => 'DESC']
  24.  
  25. ];
  26.  
  27. $result = $this->paginate($this->TableA);
  28.  
  29. $data['result'] = $result;
  30. $data['pagination'] = $this->request->getParam('paging.TableA');
  31. $data['count'] = $count;
  32.      
  33. $this->loadModel('Articles');
  34. $query = $this->Articles->find()->where($conditions)->group(['anyColumn']);
  35. $query->select(['count' => $query->func()->count('Articles.anyColumn')])->toArray();
  36.  
  37. $this->paginate($query);
  38.      
  39. $itemads = $this->paginate($itemads, ['contain' => ['Departments', 'Stores'],'group'=>'upc','fields'=>array("upc_count"=>"COUNT(`upc`)")]);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top