Skip to content

[Proposal] Add ORDER BY and LIMIT to MySQL compileUpdate #2550

@diesse

Description

@diesse

Since MySQL syntax for UPDATE statement is the following

UPDATE [LOW_PRIORITY] [IGNORE] table_reference
SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]

method compileUpdate should be extended in Illuminate/Database/Query/Grammars/MySqlGrammar.php

For example:

    public function compileUpdate(Builder $query, $values)
    {
            if ( isset($query->orders) ) {
                    $orders = ' '.$this->compileOrders($query, $query->orders);
            } else {
                    $orders = '';
            }

            if ( isset($query->limit) ) {
                    $limit = ' '.$this->compileLimit($query, $query->limit);
            } else {
                    $limit = '';
            }

            return parent::compileUpdate($query, $values).$orders.$limit;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions