This is a documentation for Board Game Arena: play board games online !
Game database model: dbmodel.sql: Revizyonlar arasındaki fark
(Created page with "In this file you specify the database schema of your game. This file contains SQL queries that will be executed during the creation of your game table. Note: you can't chang...") |
|||
(4 kullanıcıdan 5 ara revizyon gösterilmiyor) | |||
3. satır: | 3. satır: | ||
This file contains SQL queries that will be executed during the creation of your game table. | This file contains SQL queries that will be executed during the creation of your game table. | ||
Note: you can't change the database schema during the game. | '''Note:''' you can't change the database schema during the game. | ||
== Create your schema == | == Create your schema == | ||
To build this file, we recommend you to build the tables you need with the PhpMyAdmin tool (see BGA user guide), and then to export them and to copy/paste the content inside this file. | To build this file, we recommend you to build the tables you need with the PhpMyAdmin tool (see BGA user guide), and then to export them and to copy/paste the content inside this file. | ||
'''Note:''' you must not use for a column the same name as for the table, as the framework replay function relies on regexp substitution to save/restore a previous state in a clone table with another name. | |||
== Default tables == | == Default tables == | ||
27. satır: | 29. satır: | ||
* player_name: (note: you should better access this date with getActivePlayerName() or loadPlayersBasicInfos() methods) | * player_name: (note: you should better access this date with getActivePlayerName() or loadPlayersBasicInfos() methods) | ||
* player_score: the current score of the player (displayed in the player panel). You must update this field to update player's scores. | * player_score: the current score of the player (displayed in the player panel). You must update this field to update player's scores. | ||
* player_score_aux: the secondary score, used as a tie breaker. You must update this field according to tie breaking rules of the game. | * player_score_aux: the secondary score, used as a tie breaker. You must update this field according to tie breaking rules of the game (see also: [[Main_game_logic:_yourgamename.game.php#Manage_player_scores_and_Tie_breaker|Manage_player_scores_and_Tie_breaker]]) | ||
== CREATE TABLES == | |||
you can create tables, using engine InnoDB | |||
<pre> | |||
CREATE TABLE IF NOT EXISTS `hands` | |||
( | |||
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, | |||
`player_id` TINYINT(1) NOT NULL, | |||
`1` BOOL NOT NULL DEFAULT 1, | |||
`2` BOOL NOT NULL DEFAULT 1, | |||
`3` BOOL NOT NULL DEFAULT 1, | |||
`4` BOOL NOT NULL DEFAULT 1, | |||
`5` BOOL NOT NULL DEFAULT 1, | |||
`6` BOOL NOT NULL DEFAULT 1, | |||
`7` BOOL NOT NULL DEFAULT 1, | |||
PRIMARY KEY (`id`) | |||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; | |||
</pre> | |||
'''Note''': if you put comments, you cannot do it in the same line as code. | |||
Example: | |||
<pre> | |||
`3` BOOL NOT NULL DEFAULT 1, -- activated or not | |||
</pre> | |||
will also comment out `3` BOOL, and that code will not be executed. | |||
== Link == | |||
You can add your Db inits in function SetupNewGame() from file 'gamename.game.php' | |||
== Errors Log == | |||
To trace Database creation check the logs that you can access in /admin/studio. | |||
== Post-release database modification == | |||
If you want to modify your database schema after the first release of your game in production, you should consult the [[Post-release phase#Updating the database schema|related section]] |
17.56, 6 Ekim 2018 itibarı ile sayfanın şu anki hâli
In this file you specify the database schema of your game.
This file contains SQL queries that will be executed during the creation of your game table.
Note: you can't change the database schema during the game.
Create your schema
To build this file, we recommend you to build the tables you need with the PhpMyAdmin tool (see BGA user guide), and then to export them and to copy/paste the content inside this file.
Note: you must not use for a column the same name as for the table, as the framework replay function relies on regexp substitution to save/restore a previous state in a clone table with another name.
Default tables
Important: by default, BGA creates 4 tables for your game: global, stats, gamelog, and player.
You must not modify the schema of global, stats and gamelog tables (and you must not access them directly with SQL queries in your PHP code).
You may add columns to "player" table. This is very practical to add simple values associated with players.
Example:
ALTER TABLE `player` ADD `player_reserve_size` SMALLINT UNSIGNED NOT NULL DEFAULT '7';
For your information, the useful columns of default "player" table are:
- player_no: the index of player in natural playing order.
- player_id
- player_name: (note: you should better access this date with getActivePlayerName() or loadPlayersBasicInfos() methods)
- player_score: the current score of the player (displayed in the player panel). You must update this field to update player's scores.
- player_score_aux: the secondary score, used as a tie breaker. You must update this field according to tie breaking rules of the game (see also: Manage_player_scores_and_Tie_breaker)
CREATE TABLES
you can create tables, using engine InnoDB
CREATE TABLE IF NOT EXISTS `hands` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `player_id` TINYINT(1) NOT NULL, `1` BOOL NOT NULL DEFAULT 1, `2` BOOL NOT NULL DEFAULT 1, `3` BOOL NOT NULL DEFAULT 1, `4` BOOL NOT NULL DEFAULT 1, `5` BOOL NOT NULL DEFAULT 1, `6` BOOL NOT NULL DEFAULT 1, `7` BOOL NOT NULL DEFAULT 1, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
Note: if you put comments, you cannot do it in the same line as code.
Example:
`3` BOOL NOT NULL DEFAULT 1, -- activated or not
will also comment out `3` BOOL, and that code will not be executed.
Link
You can add your Db inits in function SetupNewGame() from file 'gamename.game.php'
Errors Log
To trace Database creation check the logs that you can access in /admin/studio.
Post-release database modification
If you want to modify your database schema after the first release of your game in production, you should consult the related section