SA-MP Forums Archive
if field exist sqllite - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: if field exist sqllite (/showthread.php?tid=607648)



if field exist sqllite - ratxrat - 22.05.2016

hai hai

how to check if filed is exist?
this my data
Код:
databasename : info.db
tablename : player
field : email
how to check field if(fieldexist) ?

example
Код:
if (strval(inputtext) == fieldexist)



Re: if field exist sqllite - Gammix - 22.05.2016

Do you create fields/columns dynamically ?

If no, then there is no need for checks since you make the SQL table only once.

If yes, just perform a simple query including the field and check if there is result:
pawn Код:
new DBResult:result = db_query(info, "SELECT `email` FROM `player`;");
if (result)
{
    // field exist
}
db_free_result(result);



Re: if field exist sqllite - ratxrat - 22.05.2016

im just create 1 table and 1 field , and not dynamic .

can im use like this
PHP код:
new DBResult:result db_query(info"SELECT `email` FROM `player`;");
if (
result == "test@ya.com")
{
    
// field exist
}
db_free_result(result); 



Re: if field exist sqllite - Gammix - 22.05.2016

Quote:
Originally Posted by ratxrat
Посмотреть сообщение
im just create 1 table and 1 field , and not dynamic .

can im use like this
PHP код:
new DBResult:result db_query(info"SELECT `email` FROM `player`;");
if (
result == "test@ya.com")
{
    
// field exist
}
db_free_result(result); 
That's not called checking for a field existence, i think you are checking for the email value for a specific user?
You can use the same query but with a little condition in it or maybe not (depends):
pawn Код:
db_query(db, "SELECT `email` FROM `player` WHERE `user` = 'test'");
So you can see i added a condition WHERE `user` = 'test' which actually filters that data.

For more, ****** for SQL(ite) learning to learn more deeply and clearly.