DbIsConnected: Difference between revisions

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search
Document upcoming 0.1.4 database recovery; organize wiki navigation
Release 0.1.4 BUILD133 / Protocol 36 and document authenticated event origin
 
Line 33: Line 33:
[[Category:Database Functions]]
[[Category:Database Functions]]
== Recovery from 0.1.4 ==
== Recovery from 0.1.4 ==
'''Since 0.1.4 (in development; not in public 0.1.3).''' See [[MySQL connection recovery]], [[dbReconnect]], [[dbGetConnectionState]] and [[onDatabaseConnectionStateChange]]. This function returns last-observed connection health, not a live network ping. A dead connection is marked unavailable when a worker observes the failure.
'''Since 0.1.4.''' See [[MySQL connection recovery]], [[dbReconnect]], [[dbGetConnectionState]] and [[onDatabaseConnectionStateChange]]. This function returns last-observed connection health, not a live network ping. A dead connection is marked unavailable when a worker observes the failure.

Latest revision as of 20:40, 21 September 2026

dbIsConnected

Checks whether a resource-owned database connection is still open.

Syntax

bool dbIsConnected(DatabaseConnection connection)

Parameters

Name Type Required Description
connection DatabaseConnection yes The connection to inspect.

Returns

Returns true when the connection is valid and connected; otherwise returns false.

Examples

Verify the connection before executing a query:

if dbIsConnected(db) then
    dbExec(db, "UPDATE players SET online = ?", true)
end

Notes

  • Available only in server-side resource scripts.

Recovery from 0.1.4

Since 0.1.4. See MySQL connection recovery, dbReconnect, dbGetConnectionState and onDatabaseConnectionStateChange. This function returns last-observed connection health, not a live network ping. A dead connection is marked unavailable when a worker observes the failure.