sqlx without threaded query's
PHP Code:
new g_Error[512],ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511);
if(SqlConnection == Empty_Handle) {
server_print( " optional a specific error msg " ); }
else {
server_print( " optional a ok msg ");
new szQuery[256];
formatex( szQuery, charsmax( szQuery ), "SELECT something FROM your_table");
new Handle:Query = SQL_PrepareQuery(SqlConnection, szQuery);
if(!SQL_Execute(Query)) {
server_print(" optional a specific error msg "); }
else if(SQL_Execute(Query)) {
new something[32];
SQL_ReadResult(Query, 0, something, charsmax(something));
SQL_FreeHandle(Query); SQL_FreeHandle(SqlConnection);
or with dbi but as i said this is the old way
PHP Code:
new Sql:dbc, Result:result;
dbc = dbi_connect(SQL_HOST,SQL_USER,SQL_PASS,SQL_DB,error,32);
if (dbc <= SQL_FAILED) {
server_print( "optional a specific error msg"); }
else {
new sql[512];
format(sql,511,"SELECT something FROM your_table");
result = dbi_query(dbc,sql);
if (result <= RESULT_FAILED) {
server_print(" optional a specific error msg "); }
else {
if (result == RESULT_NONE) {
server_print(" optional a specific error msg "); }
else {
new something[32] = dbi_field(result, 1);
dbi_free_result(result); } } }
Formatex is optional and the query can be used directly if there is no extra arguments.