These patterns will match most of the doctrine generated queries

@param string $query

@return array
777862
protected function getQueryInfos($query)
    {
        $type = strtolower(substr($query, 0, 6));

        switch ($type) {
            case 'select':
                $pattern = '/SELECT\s((.|\n)*)\sFROM\s(?P<table>[a-zA-Z_]*)($|(.*)$)/i';
                break;

            case 'insert':
                $pattern = '/INSERT(\s+)INTO(\s+)(?P<table>[a-zA-Z_]*)(\s*)(.*)/i';
                break;

            case 'update':
                $pattern = '/UPDATE(\s+)(?P<table>[a-zA-Z_]*)(\s*)(.*)/i';
                break;

            case 'delete':
                $pattern = '/DELETE(\s+)FROM(\s+)(?P<table>[a-zA-Z_]*)(\s*)(.*)/i';
                break;

            default:
                $type = 'other';
                $pattern = false;
        }

        if ($pattern && preg_match($pattern, $query, $matches)) {
            return array($type, $matches['table']);
        }

        return array($type, '__unknown');
    }
108339
protected function getDefaultWhere($query)
    {
        if (!request()->ajax()) {
            $query->whereRaw('(tbl_ban_management_rules.expired_at > "' . date('Y-m-d H:i:s', time()) . '")');
            return false;
        } else {
            $columns = request()->get('columns', []);
            $found   = array_where($columns, function($item, $index) {
                return strlen(array_get($item, 'search.value')) > 0;
            });
            if (empty($found)) {
                return ['tbl_ban_management_rules.status' => 1];
            }
        }
        return false;
    }
959631
public function makeQueryFiltered($query)
    {
        $settingTarget = $this->getSettingTarget();
        if ($settingTarget) {
            $query = $query->where([
                ['settable_id', '=', $settingTarget->getKeyName()],
                ['settable_type', '=', $settingTarget->getMorphClass()]
            ]);
        } else {
            $query = $query->whereNull('settable_id')->whereNull('settable_type');
        }
        return $query;
    }
464698
public function search($query) {
        $found = false;
        if (strpos(strtolower($this->name), $query) !== false) {
            $found = true;
        } else if (strpos(core_text::strtolower($this->visiblename), $query) !== false) {
                $found = true;
            }
        if ($found) {
            $result = new stdClass();
            $result->page     = $this;
            $result->settings = array();
            return array($this->name => $result);
        } else {
            return array();
        }
    }
804643
public function all($query)
    {
        $authSession = $this->repositoryDispatcher->getCookieAuthSession();

        $response = $this->client->request('POST', $this->endpoint . '/rest/api/2/search', [
            RequestOptions::HEADERS => [
                'Cookie' => $authSession->getName() . '=' . $authSession->getValue(),
            ],
            RequestOptions::JSON => $query,
        ]);

        $body = $response->getBody();
        $body->seek(0);
        $contents = $body->getContents();

        $decodedContents = json_decode($contents, true);

        $issues = [];
        if (isset($decodedContents['issues']) && is_array($decodedContents['issues'])) {
            foreach ($decodedContents['issues'] as $issue) {
                $issues[] = $this->createInstance($issue);
            }
        }

        return $issues;
    }
1156928
private function doSettlementSearch($query)
    {
        $search = ClassValidator::getInstance('Eway\Rapid\Model\SettlementSearch', $query);
        return $this->getHttpService()->getSettlementSearch($search->toArray());
    }
1180163
public function parseMethods($query, $string)
    {
        //replaces any @col(\w+) pattern with the correct column name
        if (strpos($string, '@col(')) {
            $matches = array();
            if (preg_match_all('/@col\((.*?)\)/', $string, $matches)) {
                $description = $query->getRepository()->getDescription();
                $replaces = array();
                foreach ($matches[1] as $match) {
                    $result = AnDomainQueryHelper::parseColumn($query, $match);
                    if (empty($result['columns'])) {
                        $replaces[] = $match;
                    } else {
                        $replaces[] = (string) $result['columns'];
                    }
                }

                $string = str_replace($matches[0], $replaces, $string);
            }
        }

        if (strpos($string, '@quote(')) {
            $matches = array();
            $replaces = array();
            if (preg_match_all('/@quote\((.*?)\)/', $string, $matches)) {
                foreach ($matches[1] as $match) {
                    $replaces[] = $this->_store->quoteValue($match);
                }
                $string = str_replace($matches[0], $replaces, $string);
            }
        }

        if (strpos($string, '@instanceof(')) {
            $matches = array();
            $replaces = array();
            if (preg_match_all('/\!?@instanceof\((.*?)\)/', $string, $matches)) {
                foreach ($matches[1] as $i => $match) {
                    $operand = '';
                    if ($matches[0][$i][0] == '!') {
                        $operand = 'NOT ';
                    }
                    $type_col = $query->getRepository()->getDescription()->getInheritanceColumn();
                    $classes = explode(',', $match);
                    $statements = array();
                    foreach ($classes as $class) {
                        $class = $this->_store->quoteValue($class);
                        $statements[] = $operand."FIND_IN_SET($class,$type_col)";
                    }
                    if ($operand == 'NOT ') {
                        $operand = ' AND ';
                    } else {
                        $operand = ' OR ';
                    }
                    if (count($statements) == 1) {
                        $statements = implode($operand, $statements);
                    } else {
                        $statements = '('.implode($operand, $statements).')';
                    }

                    $replaces[] = $statements;
                }
                $string = str_replace($matches[0], $replaces, $string);
            }
        }

        if (strpos($string, '@remove_from_set(')) {
            $matches = array();
            $replaces = array();
            if (preg_match_all('/@remove_from_set\((.*?)\)/', $string, $matches)) {
                foreach ($matches[1] as $i => $match) {
                    list($set, $item) = explode(',', $match);
                    $set = trim($set);
                    $item = trim($item);
                    $replaces[] = "TRIM(BOTH ',' FROM REPLACE(concat(',',$set,','),CONCAT(',',$item,','),','))";
                }

                $string = str_replace($matches[0], $replaces, $string);
            }
        }

        if (strpos($string, '@set_length(')) {
            $matches = array();
            $replaces = array();
            if (preg_match_all('/@set_length\((.*?)\)/', $string, $matches)) {
                foreach ($matches[1] as $i => $match) {
                    $replaces[] = "LENGTH($match) - LENGTH(REPLACE($match, ',', '')) + 1";
                }
                $string = str_replace($matches[0], $replaces, $string);
            }
        }

        return $string;
    }
332993
protected function normalizeDates(array $query): array
    {
        array_walk_recursive($query, function (&$value) {
            if ($value instanceof \DateTime) {
                //MongoDate is always UTC, which is good :)
                $value = new UTCDateTime($value);
            }
        });

        return $query;
    }
668612
public function getArray($query)
    {
        $this->statement = $this->db->query($query);
        if ($this->statement) {
            return $this->statement->fetch(\PDO::FETCH_ASSOC);
        }
        return false;
    }
79261
public function getResults($query)
    {
        $parameters = [];

        if (is_object($query) && $query instanceof SearchQuery) {
            $query = $query->toArray();
        }

        if (is_array($query)) {
            $collection = new Collection($query);

            $query = $collection->pull('query', '');

            $parameters = $collection->toArray();
        }

        return $this->index->search($query, $parameters);
    }
191190
public function rules($query = null)
    {
        $model = $this->model;

        // get rules from the model if set
        if (isset($model::$rules)) {
            $rules = $model::$rules;
        } else {
            $rules = [];
        }

        // if the there are no rules
        if (!is_array($rules) || !$rules) {
            // return an empty array
            return [];
        }

        // if the query is empty
        if (!$query) {
            // return all of the rules
            return array_filter($rules);
        }

        // return the relevant rules
        return array_filter(array_only($rules, $query));
    }
319826
protected function getAliases(Builder $query)
    {
        $aliases = [];

        foreach ($query->getQuery()->columns as $column) {
            if (preg_match("~AS (\w+)~i", $column, $matches)) {
                $aliases[$query->getModel()->getTable() . '.' . $matches[1]]
                    = \DB::raw(str_replace($matches[0], '', $column));
            }
        }

        return $aliases;
    }
831223
public static function plainSql($query)
    {
        $query = static::getBaseQuery($query);
        return self::inlineBindings($query->toSql(), $query->getBindings());
    }
597523
protected function performQueryAnalysis($query)
    {
        $hints = [];
        if (preg_match('/^\\s*SELECT\\s*`?[a-zA-Z0-9]*`?\\.?\\*/i', $query)) {
            $hints[] = 'Use <code>SELECT *</code> only if you need all columns from table';
        }
        if (preg_match('/ORDER BY RAND()/i', $query)) {
            $hints[] = '<code>ORDER BY RAND()</code> is slow, try to avoid if you can.
				You can <a href="http://stackoverflow.com/questions/2663710/how-does-mysqls-order-by-rand-work" target="_blank">read this</a>
				or <a href="http://stackoverflow.com/questions/1244555/how-can-i-optimize-mysqls-order-by-rand-function" target="_blank">this</a>';
        }
        if (strpos($query, '!=') !== false) {
            $hints[] = 'The <code>!=</code> operator is not standard. Use the <code>&lt;&gt;</code> operator to test for inequality instead.';
        }
        if (stripos($query, 'WHERE') === false && preg_match('/^(SELECT) /i', $query)) {
            $hints[] = 'The <code>SELECT</code> statement has no <code>WHERE</code> clause and could examine many more rows than intended';
        }
        if (preg_match('/LIMIT\\s/i', $query) && stripos($query, 'ORDER BY') === false) {
            $hints[] = '<code>LIMIT</code> without <code>ORDER BY</code> causes non-deterministic results, depending on the query execution plan';
        }
        if (preg_match('/LIKE\\s[\'"](%.*?)[\'"]/i', $query, $matches)) {
            $hints[] = 	'An argument has a leading wildcard character: <code>' . $matches[1]. '</code>.
								The predicate with this argument is not sargable and cannot use an index if one exists.';
        }
        return $hints;
    }
1090401
public static function executeRows(string $query): array
  {
    self::logQuery($query);

    return self::$dl->executeRows($query);
  }
461650
public function search($query) {
        global $CFG, $DB;
        if ($result = parent::search($query)) {
            return $result;
        }

        $found = false;
        if ($processors = get_message_processors()) {
            foreach ($processors as $processor) {
                if (!$processor->available) {
                    continue;
                }
                if (strpos($processor->name, $query) !== false) {
                    $found = true;
                    break;
                }
                $strprocessorname = get_string('pluginname', 'message_'.$processor->name);
                if (strpos(core_text::strtolower($strprocessorname), $query) !== false) {
                    $found = true;
                    break;
                }
            }
        }
        if ($found) {
            $result = new stdClass();
            $result->page     = $this;
            $result->settings = array();
            return array($this->name => $result);
        } else {
            return array();
        }
    }
43896
public function search($query) {
        global $CFG;
        if ($result = parent::search($query)) {
            return $result;
        }

        $found = false;
        $filternames = filter_get_all_installed();
        foreach ($filternames as $path => $strfiltername) {
            if (strpos(core_text::strtolower($strfiltername), $query) !== false) {
                $found = true;
                break;
            }
            if (strpos($path, $query) !== false) {
                $found = true;
                break;
            }
        }

        if ($found) {
            $result = new stdClass;
            $result->page = $this;
            $result->settings = array();
            return array($this->name => $result);
        } else {
            return array();
        }
    }