@@ -24,30 +24,22 @@ The number of rows in the result.
2424
2525// ...
2626
27- Examples_ListNames (DB: dbConnectionHandle )
27+ Examples_CountVehicles (DB: dbConnectionHandle )
2828{
2929 // Database result set
30- new DBResult: db_result_set = DB_ExecuteQuery("SELECT ` name ` FROM ` examples ` ");
30+ new DBResult: db_result_set = DB_ExecuteQuery("SELECT ` uid ` FROM ` vehicles ` ");
3131
3232 // If database result set is valid
3333 if (db_result_set)
3434 {
35- // Allocate some memory to store results
36- new result[256];
37-
38- // Do operations
39- do
40- {
41- // Add value from "example" field to the return value variable
42- DB_GetFieldStringByName(db_result_set, "name", result, sizeof result);
43- }
44-
45- // While next row could be fetched
46- while (DB_SelectNextRow(db_result_set));
35+ new row_count = DB_GetRowCount(db_result_set);
4736
4837 // Free result set
4938 DB_FreeResultSet(db_result_set);
39+
40+ return rowcount;
5041 }
42+ return 0;
5143}
5244```
5345
@@ -74,7 +66,7 @@ public OnGameModeInit()
7466 {
7567 // Successfully created a connection to the database
7668 print("Successfully created a connection to database \"example.db\".");
77- Examples_ListNames( gDBConnectionHandle);
69+ printf("%i vehicles are stored in the database", Examples_CountVehicles( gDBConnectionHandle) );
7870 }
7971 else
8072 {
@@ -116,7 +108,6 @@ Using an invalid handle other than zero will crash your server! Get a valid data
116108- [ DB_Close] ( DB_Close ) : Close the connection to an SQLite database
117109- [ DB_ExecuteQuery] ( DB_ExecuteQuery ) : Query an SQLite database
118110- [ DB_FreeResultSet] ( DB_FreeResultSet ) : Free result memory from a DB_ExecuteQuery
119- - [ DB_GetRowCount] ( DB_GetRowCount ) : Get the number of rows in a result
120111- [ DB_SelectNextRow] ( DB_SelectNextRow ) : Move to the next row
121112- [ DB_GetFieldCount] ( DB_GetFieldCount ) : Get the number of fields in a result
122113- [ DB_GetFieldName] ( DB_GetFieldName ) : Returns the name of a field at a particular index
0 commit comments