mariadb get affected rows: Difference between revisions

From Onset Developer Wiki
(Created page with "{{Info|Function|Server|1.0}} {{Notice|This function is provided by the official MariaDB plugin.}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|mariadb_get_affected_rows(...")
 
No edit summary
 
(One intermediate revision by one other user not shown)
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|__EDIT_ME__}}
{{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 9: Line 9:
{{FuncNoParam}}
{{FuncNoParam}}


{{FuncReturnValue|__EDIT_ME__}}
{{FuncReturnValue|Number of affected rows. '''false''' on error.}}


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


{{RelatedFunctions}}
{{RelatedFunctions}}
__EDIT_ME__
{{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