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
:whereto target specific rows for updating - Multiple updates — chain multiple
:updatecalls to append additional column updates - Multiple conditions — chain multiple
:wherecalls to apply additional filters to the update - Without conditions — omitting
:wherewill update all rows in the table
Parameters
| Type | Name | Description |
|---|---|---|
table | data | A 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
| Type | Name | Description |
|---|---|---|
db_query / bool | query | Query 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()