SA-MP Forums Archive
Varchar Mysql - 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: Varchar Mysql (/showthread.php?tid=594829)



Varchar Mysql - vassilis - 23.11.2015

How can i set a string for varchar variable when i insert it through code?
I want when my player creates a house to set a string 'Unowned' and 'No Owner' to variables(varchared vars) HName and HOwner at the database how i can do that?


Re: Varchar Mysql - Jefff - 23.11.2015

in create table use VARCHAR(25) DEFAULT 'No Owner'


Re: Varchar Mysql - vassilis - 23.11.2015

Quote:
Originally Posted by Jefff
Посмотреть сообщение
in create table use VARCHAR(25) DEFAULT 'No Owner'
i dont create table through my programm i have already created a table is there a way to insert it later when the player created the house?


Re: Varchar Mysql - Jefff - 23.11.2015

Try
pawn Код:
ALTER TABLE table_name ALTER COLUMN HOwner VARCHAR(25) DEFAULT 'No Owner'



Re: Varchar Mysql - vassilis - 23.11.2015

Ok thanks and one last question if i make it manually through table do i have at default to use ' or just write inside the field the text?


Re: Varchar Mysql - Vince - 23.11.2015

"Unknown" values should be represented by NULL. Processing of this information is to be done in code, not in the database.

Furthermore, Owner should be linked to the player's unique id in the player table. A player's name is only to appear once in the entire database. Any other tables that require the player's information must link to the original table via a foreign key.


Re: Varchar Mysql - vassilis - 23.11.2015

Umm i dropped the houses table and recreated manually and set default the texts i want and i just read vince's reply . Here is a picture of my structure of the table should i change something? Have i done something wrong?