mariadb get affected rows: Difference between revisions

From Onset Developer Wiki
28days (talk | contribs)
No edit summary
No edit summary
 
Line 2: Line 2:
{{Notice|This function is provided by the official [[MariaDB]] plugin.}}
{{Notice|This function is provided by the official [[MariaDB]] plugin.}}


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


{{FuncSyntax|mariadb_get_affected_rows()}}
{{FuncSyntax|mariadb_get_affected_rows()}}
Line 12: Line 12:


== Example ==
== Example ==
<syntaxhighlight lang="Lua>
<syntaxhighlight lang="Lua">
__EDIT_ME__
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
</syntaxhighlight>
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
{{Template:MariaDBFunctions}}
{{Template:MariaDBFunctions}}

Latest revision as of 08:50, 2 September 2020

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