1
0

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 1 year has passed since last update.

CakePHPでリレーション 先のテーブルの条件検索

Posted at

matchingを使う。

matchingの使い方。

$user_id = $this->request->user_id;


$query = $users->find()
    ->matching('relation', function ($q) use ($user_id) { // useで定義した変数が使えるようになる。
                return $q
                ->where(['
                  relation.user_id => $user_id,
                  relation.created_at => '2022-07-15'
             })
    ->limit(10)->offset($offset);
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?