Raised This Month: $51 Target: $400
 12% 

SQL_GetRowCount


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
IceCucumber
Member
Join Date: Dec 2011
Old 05-12-2015 , 15:16   SQL_GetRowCount
Reply With Quote #1

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?
IceCucumber is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-12-2015 , 15:26   Re: SQL_GetRowCount
Reply With Quote #2

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.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
IceCucumber
Member
Join Date: Dec 2011
Old 05-12-2015 , 15:30   Re: SQL_GetRowCount
Reply With Quote #3

Ah. Thank you.
IceCucumber is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:32.


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