LoginSignup
4
3

More than 5 years have passed since last update.

CakePHPでModel::find()にて部分一致の検索機能の実装

Last updated at Posted at 2016-02-25

Model::find()で検索

http://book.cakephp.org/2.0/ja/models/retrieving-your-data.html

'conditions'に検索条件を指定できる.
配列で渡せば, 複数の検索条件を指定できる.

sample.php
$this->Model->find(array(  
    'conditions' => array(  
        'Model.field1' => '検索ワード1',
        'Model.field2' => '検索ワード2',
        )
    ));

部分一致の検索を行う

LIKE, 及びワイルドカード'%'を用いる.

sample2.php
$this->Model->find(array(
    'conditions' => array(
            'Model.field LIKE' => '%'.'部分一致ワード'.'%'
            )
        ));
4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3