mysql help - 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: mysql help (
/showthread.php?tid=408489)
mysql help -
Richie© - 18.01.2013
Im no expert in mysql, so ill ask here and maybe some of you guys know what to do
I have code in OnGameModeInit to create tables in the database if they dont exist.
pawn Код:
CREATE TABLE IF NOT EXISTS ....
I also want to insert 10 rows of information to, its actually just 1 field of information that is important to be created, the ID field.
I tried a x10 loop with:
What i didnt think about is that it will create 10 new rows every time OnGameModeInit is called.
So the question is, how do i make it detect if the 10 rows are already in the DB?
Re: mysql help -
InfiniTy. - 18.01.2013
Erm.. why not just delete the code ? Or store it somewhere and when you need to insert it in DB just paste it in phpmyadmin or whatever you have.. ?O.o
Re: mysql help -
AndreT - 18.01.2013
It depends on what sort of information you're storing in your table, I guess, but the only way to approach this issue of yours is using a
SELECT query.
You can, for instance, select the number of rows in the table.
SELECT COUNT(*) FROM table
Then the first and only value returned by the query is the amount of rows. Retrieve this (either using the regular mysql_* functions or maybe the cache feature, check my signature for that) value and see if it is 10. If no, insert the rows.
Re: mysql help -
Richie© - 18.01.2013
AndreT, you are awesome! Thank you so much!
Edit: You must spread some Reputation around before giving it to AndreT again.