6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CakePHPであいまい検索を行う方法 (find, 部分一致)

Last updated at Posted at 2016-12-27

○○を含むという部分一致の検索をする時は以下のように記述する。

▼ 書き方

$this->Model->find(array(
    'conditions' => array('Model.Field LIKE' => '%'. '検索したいワード'. '%')
));

▼ おまけ

その他のfindのオプションは以下の様に記述する。

find('all',array(
    'fields' => array('Model.field1','Model.field2'), //取得するカラム。配列指定。
    'conditions' => array('Model.field' => $thisValue), //検索条件。カラムと値を連想配列で指定。
    'order' => array('Model.created', 'Model.field3 DESC'), //並び順。文字列または配列で指定。
    'group' => array('Model.field'), //group byするカラム。
    'limit' => 2, //limit句。数値で渡す。
    'recursive'=>-1//
))
6
6
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
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?