Expose MySQL connection state

This commit is contained in:
root
2026-07-17 18:05:04 +00:00
parent da04af1cbf
commit 3e423f49dd
5 changed files with 36 additions and 2 deletions
+20
View File
@@ -0,0 +1,20 @@
:sig
bool mysql_connected(MySQL* m)
:params
m : pointer returned by mysql_connect()
return value : true only when the wrapper owns a live server connection
:see
>mysql
:content
Tests whether a MySQL wrapper has a usable server connection. `mysql_connect()` retains a failed wrapper so that callers can retrieve its diagnostic through `mysql_error()`; this helper distinguishes that state from a live handle without consuming the diagnostic.
:example
MySQL* db = mysql_connect();
if(!mysql_connected(db))
{
print("database unavailable: ", mysql_error(db), "\n");
}
if(db != 0) mysql_disconnect(db);