mariadb get affected rows

From Onset Developer Wiki
Revision as of 08:50, 2 September 2020 by BlueMountains (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
mariadb get affected rows

Type: Function
Context: Server
Introduced: v1.0

NOTICE

This function is provided by the official MariaDB plugin.

Description

Returns the number of affected rows if the query was a CRUD (Create, read, update and delete) query.

Syntax

mariadb_get_affected_rows()

Parameters

  • This function has no parameters.

Return Value

  • Number of affected rows. false on error.

Example

function UpdateVehicles()
    local query = mariadb_prepare(sql, "UPDATE vehicles SET owner = 0 WHERE model = 34;")
    mariadb_async_query(sql, query, OnUpdateVehicles)
end

function OnUpdateVehicles()
    local affected_rows = mariadb_get_affected_rows()
    print("Number of vehicles updated: ", affected_rows)
end

See also