AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   SQL_GetRowCount (https://forums.alliedmods.net/showthread.php?t=262795)

IceCucumber 05-12-2015 15:16

SQL_GetRowCount
 
Hey. I'm running into some confusion with SourceMod's SQL_GetRowCount.

I'm able to create tables, insert/update data etc. But the following code always returns 1:
PHP Code:

// Get number of rows in table "competitive_overlay"
new Handle:hSQL_RowCount SQL_Query(g_hSQL"SELECT COUNT(*) FROM `competitive_overlay`;");
new 
rowCount SQL_GetRowCount(hSQL_RowCount);
CloseHandle(hSQL_RowCount);
PrintToServer("Row count: %i"rowCount); // This is always 1 

Running "SELECT COUNT(*) FROM `competitive_overlay`" directly in the SQL server returns the actual row count just fine. Am I doing something wrong here?

Exolent[jNr] 05-12-2015 15:26

Re: SQL_GetRowCount
 
Because the number of rows returned is not the same number as COUNT(*).
It returns 1 row with the value of the COUNT(*).
So you have to fetch the first integer value from the row given.

IceCucumber 05-12-2015 15:30

Re: SQL_GetRowCount
 
Ah. Thank you.


All times are GMT -4. The time now is 19:36.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.