[Ajuda] Duvida sobre MySql
#1

Olб !

Eu comeзei a estudar MySql ontem de noite, e terminei de criar meu sistema de login e registro hoje, estou conseguindo puxar todos meus dados da tabela, mas quando fui puxar a data de um campo varchar(100) ele nгo me retorna nada, exemplo:

pawn Код:
enum pInfo{
    pUltimoLogin
};
new PlayerInfo[MAX_PLAYERS][pInfo], StrFormat[126];
Fields:


Setando o content do campo na variavel...
pawn Код:
cache_get_field_content(0,"pUltimoLogin",Query);
PlayerInfo[playerid][pUltimoLogin] = strval(Query);
Formatando..
pawn Код:
format(StrFormat, sizeof(StrFormat), "Ultimo login: %s", PlayerInfo[playerid][pUltimoLogin]); // Em forma de strings, nгo sei se estб correto
SendClientMessage(playerid, -1, PlayerInfo[playerid][pUltimoLogin]);
Verifiquei no mysql_log.txt e tem isto:
Код:
[17:42:03] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[17:42:03] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[17:42:03] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[17:42:03] [DEBUG] CMySQLConnection::Connect - connection was successful
[17:42:03] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[17:42:03] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
Ao spawnar...
Код:
[17:45:10] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `users` WHERE name='Clandok'", callback: "r@MySQL_CheckAccount", format: "d"
[17:45:10] [DEBUG] CMySQLQuery::Execute[r@MySQL_CheckAccount] - starting query execution
[17:45:10] [DEBUG] CMySQLQuery::Execute[r@MySQL_CheckAccount] - query was successfully executed within 2.407 milliseconds
[17:45:10] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[17:45:10] [DEBUG] Calling callback "r@MySQL_CheckAccount"..
[17:45:10] [DEBUG] cache_get_data - connection: 1
[17:45:10] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[17:45:13] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `users` WHERE name='Clandok' AND password='1234'", callback: "r@MySQL_CheckPassword", format: "d"
[17:45:13] [DEBUG] CMySQLQuery::Execute[r@MySQL_CheckPassword] - starting query execution
[17:45:13] [DEBUG] CMySQLQuery::Execute[r@MySQL_CheckPassword] - query was successfully executed within 3.542 milliseconds
[17:45:13] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[17:45:13] [DEBUG] Calling callback "r@MySQL_CheckPassword"..
[17:45:13] [DEBUG] cache_get_data - connection: 1
[17:45:13] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `users` WHERE name='Clandok'", callback: "r@MySQL_LoadAccount", format: "d"
[17:45:13] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[17:45:13] [DEBUG] CMySQLQuery::Execute[r@MySQL_LoadAccount] - starting query execution
[17:45:13] [DEBUG] CMySQLQuery::Execute[r@MySQL_LoadAccount] - query was successfully executed within 0.951 milliseconds
[17:45:13] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[17:45:13] [DEBUG] Calling callback "r@MySQL_LoadAccount"..
[17:45:13] [DEBUG] cache_get_data - connection: 1
[17:45:13] [DEBUG] cache_get_field_content - row: 0, field_name: "level", connection: 1, max_len: 500
[17:45:13] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "level", data: "200"
[17:45:13] [DEBUG] cache_get_field_content - row: 0, field_name: "admin", connection: 1, max_len: 500
[17:45:13] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "admin", data: "1"
[17:45:13] [DEBUG] cache_get_field_content - row: 0, field_name: "money", connection: 1, max_len: 500
[17:45:13] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "money", data: "1500"
[17:45:13] [DEBUG] cache_get_field_content - row: 0, field_name: "bank", connection: 1, max_len: 500
[17:45:13] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "bank", data: "0"
[17:45:13] [DEBUG] cache_get_field_content - row: 0, field_name: "skin", connection: 1, max_len: 500
[17:45:13] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "skin", data: "10"
[17:45:13] [DEBUG] cache_get_field_content - row: 0, field_name: "pUltimoLogin", connection: 1, max_len: 500
[17:45:13] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "pUltimoLogin", data: "08/01/2015"
[17:45:13] [DEBUG] cache_get_field_content - row: 0, field_name: "m_jogados", connection: 1, max_len: 500
[17:45:13] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "m_jogados", data: "616"
[17:45:13] [DEBUG] cache_get_field_content - row: 0, field_name: "PosX", connection: 1, max_len: 500
[17:45:13] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "PosX", data: "680.01"
[17:45:13] [DEBUG] cache_get_field_content - row: 0, field_name: "PosY", connection: 1, max_len: 500
[17:45:13] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "PosY", data: "1498.003"
[17:45:13] [DEBUG] cache_get_field_content - row: 0, field_name: "PosZ", connection: 1, max_len: 500
[17:45:13] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "PosZ", data: "8.886"
[17:45:13] [DEBUG] cache_get_field_content - row: 0, field_name: "CamX", connection: 1, max_len: 500
[17:45:13] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "CamX", data: "676.445"
[17:45:13] [DEBUG] cache_get_field_content - row: 0, field_name: "CamY", connection: 1, max_len: 500
[17:45:13] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "CamY", data: "1499.687"
[17:45:13] [DEBUG] cache_get_field_content - row: 0, field_name: "CamZ", connection: 1, max_len: 500
[17:45:13] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "CamZ", data: "10.218"
[17:45:13] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
No log pareзe que pega o content do campo "pUltimoLogin"
Код:
[17:45:13] [DEBUG] cache_get_field_content - row: 0, field_name: "pUltimoLogin", connection: 1, max_len: 500
[17:45:13] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "pUltimoLogin", data: "08/01/2015"
Serб que tenho que limpar o cache ?
Quem poder ajudar eu agradeзo.
Reply
#2

tenta assim!

pawn Код:
cache_get_field_content(0,"pUltimoLogin",PlayerInfo[playerid][pUltimoLogin]);
Reply
#3

Obrigado pela resposta, olha, nгo retornou nada ainda.
Reply
#4

por que vocк tб fazendo strval em um campo de texto ?
Reply
#5

Obrigado pela resposta Willian, eu segui este tutorial do BlueX: forum.sa-mp.com/showthread.php?t=356261
Sobre a strval estou estudando a funзгo agora. No caso, oque devo fazer ?

Usei o mйtodo do mau.tito sem strval e nгo funcionou .
Reply
#6

a partir da maneira como vocк estб fazendo, execute testes para saber se os dados estгo sendo restaurados do banco.

pawn Код:
cache_get_field_content(0,"pUltimoLogin",Query);
print(Query);
Se por acaso o valor imprimido estiver correto, indica que a forma como vocк estб tratando o seu resultado estб errada, como usar strval...

strval й uma funзгo para converter string para inteiro, como "110" = 110, com tudo, no banco vocк tem caracteres especiais que nгo sгo reconhecidos como inteiro, tipo a barra "/".


Execute esse teste que te falei, aguardo respostas.
Reply
#7

"08/01/2015" Printou no console.

Agora, como trato isto, estou sem ideias hehe, e obrigado novamente !
Reply
#8

jб tб tratado na var "Query", se vocк deseja armazenar isso para futuros usos, entгo vai ter que criar uma var global... Com esse enumerador e essa var que vocк criou nгo serб possнvel armazenar strings...

exemplo:
pawn Код:
//topo do gm
new ultimoLogin[MAX_PLAYERS][15];

//cуdigo de consulta
format(ultimoLogin[playerid], 15, "%s", Query);
Reply
#9

Muito obrigado Willian e mau.tito, tenho que estudar mais sobre enumeradores =D, vou procurar saber mais e mais, atй =D
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)