Vital.sandbox
Database

db_query:insert

Server

Appends a row insertion to the query


Syntax

local query = db_query:insert(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 data to insert
  • Multiple insertions — chain multiple :insert calls to append additional row insertions

Parameters

TypeNameDescription
tabledataA key-value table defining the row to insert
• Keys represent column names
• Values represent the data to insert — 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")

--Insert a new player record
db:table("players")
    :insert({ name = "aviril", score = 0 })
    :execute()

On this page