Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public OnFilterScriptInit()
- {
- new somevar = 1337;
- mysql_debug(1);
- new con = mysql_connect(host, user, db, pass);
- // Table structure: id|username|pass|money
- format(string, sizeof string, "SELECT * FROM `users`");
- mysql_function_query(con, string, true, "Test", "i", somevar);
- return 1;
- }
- public Test(somevar)
- {
- new rows, fields, szRow[128];
- cache_get_data(rows, fields);
- for(new i;i < rows;i++) {
- szRow = fetch_field_content("username", i, fields);
- printf("Username = %s", szRow);
- szRow = fetch_field_content("money", i, fields);
- printf("Username = %s", szRow);
- }
- // returning 1 at the end means the cache & memory will be automatically free'd
- return 1;
- }
- // mysql_fetch_field_row() alias
- stock fetch_field_content(fieldname[], row, fields)
- {
- new szField[40], szRow[128];
- for(new i;i < fields;i++) {
- cache_get_field(i, szField);
- if(!strcmp(szField, fieldname)) {
- cache_get_row(row, i, szRow);
- break;
- }
- }
- return szRow;
- }
Add Comment
Please, Sign In to add comment