Clockwork\DataSource\EloquentDataSource::createRunnableQuery PHP Method

createRunnableQuery() protected method

Takes a query, an array of bindings and the connection as arguments, returns runnable query with upper-cased keywords
protected createRunnableQuery ( $query, $bindings, $connection )
    protected function createRunnableQuery($query, $bindings, $connection)
    {
        # add bindings to query
        $bindings = $this->databaseManager->connection($connection)->prepareBindings($bindings);
        foreach ($bindings as $binding) {
            $binding = $this->databaseManager->connection($connection)->getPdo()->quote($binding);
            $query = preg_replace('/\\?/', $binding, $query, 1);
        }
        # highlight keywords
        $keywords = ['select', 'insert', 'update', 'delete', 'where', 'from', 'limit', 'is', 'null', 'having', 'group by', 'order by', 'asc', 'desc'];
        $regexp = '/\\b' . implode('\\b|\\b', $keywords) . '\\b/i';
        $query = preg_replace_callback($regexp, function ($match) {
            return strtoupper($match[0]);
        }, $query);
        return $query;
    }