Vital.sandbox
Database

db_query:update

Server

Appends a row update to the query


Syntax

local query = db_query:update(data)

This function only prepares the query and does not execute it. Chain db_query:execute at the end to commit the query to the database.

  • Data — accepts a key-value table where each key is a column name and each value is the new data to apply
  • Chaining — compatible with :where to target specific rows for updating
  • Multiple updates — chain multiple :update calls to append additional column updates
  • Multiple conditions — chain multiple :where calls to apply additional filters to the update
  • Without conditions — omitting :where will update all rows in the table

Parameters

TypeNameDescription
tabledataA key-value table defining the columns to update
• Keys represent column names
• Values represent the new data to apply — accepted types are string and number

Returns

TypeNameDescription
db_query / boolqueryQuery builder instance on successful execution, or false on failure

Examples

local db = database.create("127.0.0.1", "root", "", "vital_sandbox")

--Update the score for a specific player
db:table("players")
    :update({ score = 500 })
    :where("name", "=", "aviril")
    :execute()

On this page