Skip to content

MySQL Module ConnectionClass insert

DizzasTeR edited this page Jan 30, 2021 · 4 revisions

MySQL Connection

insert

Performs an insertion query and returns the last inserted row id

int MySQLConnection:insert([function callback, ] string query [, ...optionalParameters])

Parameters

  • optional string function — Function to call with the last row id (OPTIONAL)
  • string query — The query to execute
  • optional optionalParameters — Forward any extra parameters with the query (Used for prepared statements)

Returns

int - Last row id or false if something went wrong

Example

local row_id = connection:insert("INSERT INTO test_table (name) VALUES (?)", {"omaigawd2"})
if row_id ~= false then
    print("Received row id: "..tostring(row_id))
end
Clone this wiki locally