[CakePHP 3.x]独自findメソッド2パターン
controller
$this->AdAddress = TableRegistry::get('AdAddress'); $this->AdAddress->find('jeff',['limit' => 30]);
$this->AdAddress = TableRegistry::get('AdAddress'); $this->AdAddress->find('jack');
AdAddressTable.php
<?php namespace App\Model\Table; use Cake\ORM\Query; use Cake\ORM\Table; class AdAddressTable extends TableEx { public function findJeff(Query $query, array $options) { return $query->group(['city_id'])->order(['id' => 'ASC'])->all(); } public function findJack(Query $query, array $options) { return $this->find()->group(['city_id'])->order(['id' => 'ASC'])->limit(3); } }