Jump to content
  • 0

Generare numar din mysql_query


BuNiCu-RP

Question

Problema intalnita (descriere): Nu reusesc sa generez numarul de rezultate din mysql_query
Ero(area / rile) / warning-(ul / urile): Nu sunt erori
Liniile de cod / sursa / script-ul(obligatoriu): 

stock CheckJobWorker(jID)
{
    new query[128], rows, fields;
    format(query, sizeof(query), "SELECT COUNT(*) FROM `users` WHERE `Job` = '%d'", jID);
	mysql_query(SQL, "SELECT COUNT(*) FROM `users` WHERE `Job` = 1", true);
	cache_get_data(rows, fields, SQL);
    printf("%d | %d workers", rows, fields);
 	return 0;
}


Imagini / Video (optional): - 
Ati incercat sa rezolvati singur?: - Ma bat cu codul de 30 minute, in phpmyadmin imi arata la select 7, in gm imi genereaza 1..

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Salut,

Ce versiune de MySQL folosesti?

Iti las aici codul pentru R30+.

forward @CheckJobWorker(jID);

public @CheckJobWorker()
{
	printf("%d workers", cache_get_field_content_int(0, "total_rows", SQL)); // Preiei numarul din coloana "total_rows".
}

CheckJobWorker(jID)
{
    new query[128], rows, fields;
    format(query, sizeof(query), "SELECT COUNT(*) as total_rows FROM `users` WHERE `Job` = '%d'", jID); // Mai adaugi si "as total_rows" sa ii dai un nume acelui "COUNT(*)".
	mysql_pquery(SQL, query, "@CheckJobWorker"); // Executi interogarea pe un alt thread.
}

 

  • Upvote 1
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.