gm_tmysql4 icon indicating copy to clipboard operation
gm_tmysql4 copied to clipboard

Query callback not called on failure

Open Yahzy opened this issue 9 months ago • 3 comments

When executing a query that fails, the callback is not triggered. In version 4.0, the callback was called regardless of the query result. Would it be possible to restore this behavior pls ?

Yahzy avatar Feb 19 '25 00:02 Yahzy

img

aStonePenguin avatar Feb 19 '25 17:02 aStonePenguin

I don't know if it's because I'm on a local 32-bit Windows server, but it doesn't print anything to me and this only happens with versions higher than 4.0

require("tmysql4")

database = database or {}
database.handle = database.handle or nil
database.error = database.error or nil

database.handle, database.error = tmysql.Connect("localhost", "root", "", "server", 3306)
if database.error then print("Error: ", database.error) return end

print("start")
database.handle:Query("CREATE TABLE IF NOT EXISTS `test` (`id` CHAR(50) PRIMARY KEY, `value` TEXT);")
database.handle:Query("SELECT * FROM `test`", PrintTable)

In this example, no print is placed in my console apart from print("start"). And the first query proves that the connection works very well

Yahzy avatar Feb 19 '25 17:02 Yahzy

You need to manually poll the connection in this version.

hook.Add('Think', database.handle, database.handle.Poll)

aStonePenguin avatar Feb 24 '25 23:02 aStonePenguin