+ /**
+ * @param string|array $options
+ * @return bool
+ */
+ private function selectOptionsIncludeLocking( $options ) {
+ $options = (array)$options;
+ foreach ( [ 'FOR UPDATE', 'LOCK IN SHARE MODE' ] as $lock ) {
+ if ( in_array( $lock, $options, true ) ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @param array|string $fields
+ * @param array|string $options
+ * @return bool
+ */
+ private function selectFieldsOrOptionsAggregate( $fields, $options ) {
+ foreach ( (array)$options as $key => $value ) {
+ if ( is_string( $key ) ) {
+ if ( preg_match( '/^(?:GROUP BY|HAVING)$/i', $key ) ) {
+ return true;
+ }
+ } elseif ( is_string( $value ) ) {
+ if ( preg_match( '/^(?:DISTINCT|DISTINCTROW)$/i', $value ) ) {
+ return true;
+ }
+ }
+ }
+
+ $regex = '/^(?:COUNT|MIN|MAX|SUM|GROUP_CONCAT|LISTAGG|ARRAY_AGG)\s*\\(/i';
+ foreach ( (array)$fields as $field ) {
+ if ( is_string( $field ) && preg_match( $regex, $field ) ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+