[Tutorial] How to: SQLite
#26

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
Oh that sucks D: It's gonna take a while, I may as well just code a system for saving data rather than writing the queries.

This is what put me off SQL, it's just so long and drawn out to save small parts of data!


I'm going to use strcat and a similar system to my file script to build a query string from input data to be updated or created.
Well you can use your method by using the escape char, that's a pretty good idea if you have trouble reading the data, but if you just take the time to write it out. It's almost like writing a chunk of file-based saving code. Shouldn't take you longer than 10 minutes.

For me, it's easiest to read it like this.
pawn Код:
format(string1, 500, "UPDATE `Users` SET Password = '%s', Level = '%d', \
                      AdminLevel = '%d', VIPLevel = '%d', ConnectedTime = '%d', \
                      Sex = '%d', Age = '%d', Origin = '%d', Muted = '%d', \
                      Respect = '%d', Cash = '%d', BankAccount = '%d', \
                      Kills = '%d', Deaths = '%d', WantedDeaths = '%d', \
                      TimesArrested = '%d', Phonebook = '%d', Number = '%d', LottoNumber = '%d', "
,

    db_escape(PlayerInfo[playerid][pKey]),
    PlayerInfo[playerid][pLevel],
    PlayerInfo[playerid][pAdminLevel],
    PlayerInfo[playerid][pVip],
    PlayerInfo[playerid][pConnectTime],
    PlayerInfo[playerid][pSex],
    PlayerInfo[playerid][pAge],
    PlayerInfo[playerid][pOrigin],
    PlayerInfo[playerid][pMuted],
    PlayerInfo[playerid][pRespect],
    PlayerInfo[playerid][pCash],
    PlayerInfo[playerid][pBank],
    PlayerInfo[playerid][pKills],
    PlayerInfo[playerid][pDeaths],
    PlayerInfo[playerid][pWantedDeaths],
    PlayerInfo[playerid][pTimesArrested],
    PlayerInfo[playerid][pPhoneBook],
    PlayerInfo[playerid][pNumber],
    PlayerInfo[playerid][pLotto]
);
Then format the rest of the data, finish the second query, strcat them together, and query them.
Reply


Messages In This Thread
How to: SQLite (basic tutorial) - by __ - 17.06.2011, 22:54
Re: How to: SQLite - by __ - 17.06.2011, 23:06
Re: How to: SQLite - by Lorenc_ - 18.06.2011, 02:52
Re: How to: SQLite - by cessil - 18.06.2011, 05:33
Re: How to: SQLite - by __ - 18.06.2011, 11:32
Re: How to: SQLite - by Lorenc_ - 18.06.2011, 11:42
Re: How to: SQLite - by __ - 18.06.2011, 11:50
Re: How to: SQLite - by __ - 16.07.2011, 20:14
Re: How to: SQLite - by Jonny5 - 25.04.2012, 16:53
Re: How to: SQLite - by __ - 25.04.2012, 16:56
Re: How to: SQLite - by System64 - 25.04.2012, 17:33
Re: How to: SQLite - by ReneG - 13.05.2012, 17:32
Re: How to: SQLite - by __ - 14.06.2012, 10:08
Re: How to: SQLite - by Rudy_ - 14.06.2012, 10:12
Re: How to: SQLite - by Calgon - 14.06.2012, 10:17
Re: How to: SQLite - by __ - 14.06.2012, 10:18
Re: How to: SQLite - by Kindred - 14.06.2012, 10:44
Re: How to: SQLite - by __ - 14.06.2012, 10:47
Re: How to: SQLite - by TheLazySloth - 15.06.2012, 00:22
Re: How to: SQLite - by ReneG - 15.06.2012, 01:24
Re: How to: SQLite - by __ - 15.06.2012, 07:16
Re: How to: SQLite - by ReneG - 15.06.2012, 07:21
Re: How to: SQLite - by ReneG - 15.06.2012, 07:44
Re: How to: SQLite - by TheLazySloth - 15.06.2012, 16:14
Re: How to: SQLite - by Jonny5 - 15.06.2012, 16:29
Re: How to: SQLite - by ReneG - 15.06.2012, 17:11
Re: How to: SQLite - by kingchandio - 17.06.2012, 10:22
Re: How to: SQLite - by Calgon - 17.06.2012, 16:56
Re: How to: SQLite - by kingchandio - 17.06.2012, 21:01
Re: How to: SQLite - by Calgon - 17.06.2012, 22:50
Re: How to: SQLite - by Dodo9655 - 24.06.2012, 09:48
Re: How to: SQLite - by Kreatyve - 12.10.2012, 17:33
Re: How to: SQLite - by Guest4390857394857 - 22.02.2014, 13:46

Forum Jump:


Users browsing this thread: 1 Guest(s)