where( [ 'gallery' => true, ] ) ->all(); } /** * @param array $images */ public function saveImages(array $images) { if (empty($images)) { \Yii::$app->db->createCommand() ->update( 'ImageManager', [ 'gallery' => false, ], '1 = 1' ) ->execute(); } else { $condition = 'id IN (' . implode(',', $images) . ')'; \Yii::$app->db->createCommand() ->update( 'ImageManager', [ 'gallery' => true, ], $condition ) ->execute(); } } }