11# DataProvider
22[ ![ Build Status] ( https://scrutinizer-ci.com/g/VectorNetworkProject/DataProvider/badges/build.png?b=master )] ( https://scrutinizer-ci.com/g/VectorNetworkProject/DataProvider/build-status/master )
33
4- データを格納するためのプラグイン
4+ データを格納するためのプラグイン
5+ ## テーブル
56
6- ##使い方
7+ ### ** accounts **
78
9+ | Column | Type | Description |
10+ | :----: | :---: | :---------: |
11+ | id | int | 登録したときに自動的に付与されます |
12+ | name | string | プレイヤーの名前です。 |
13+
14+ UserdataProviderで基本となる情報を扱うテーブルです。ここに記載されたIDをもとに各テーブルの管理を行います。
15+ sqlite.sql上ではidをメインにやり取りしていますが、デベロッパーが扱う際はラップしたクラス群の関数を使ってください。
16+
17+ ### ** ffapvp**
18+
19+ | Column | Type | Description |
20+ | :----: | :---: | :---------: |
21+ | id | int | プレイヤーと対応するaccountsテーブルのid |
22+ | kill | int | キル数 |
23+ | death | int | デス数 |
24+ | exp | int | EXP |
25+
26+ ### ** dual**
27+
28+ | Column | Type | Description |
29+ | :----: | :---: | :---------: |
30+ | id | int | プレイヤーと対応するaccountsテーブルのid |
31+ | kill | int | キル数 |
32+ | death | int | デス数 |
33+ | win | int | 勝利数 |
34+ | lose | int| 敗北数 |
35+
36+ ## 使い方
837``` PHP
938public function onEnable()
1039{
@@ -15,10 +44,21 @@ public funciton onPlayerJoin(PlayerJoinEvent $event)
1544{
1645 $this->accounts->get(
1746 $event->player,
18- function (array $rows) use($player)
47+ function(array $rows) use($player): void
1948 {
20- $player->sendMessage("あなたのIDは$raws[0][id]です");
49+ if($rows[0] !== null)
50+ {
51+ $player->sendMessage("あなたのIDは$raws[0][id]です");
52+ }
53+ },
54+ function(SqlError $error, ?Exception $trace): void //https://github.com/poggit/libasynql/blob/master/libasynql/src/poggit/libasynql/base/DataConnectorImpl.php#L196
55+ {
56+ var_dump($error, $trace);
2157 }
2258 );
2359}
24- ``````
60+ ```
61+
62+ クエリの終了時、またはエラー時の際の処理をクロージャで渡してください。
63+ 終了時の引数は` array $rows ` で結果が` $rows[<順番>][<カラム名>] ` で格納されます。エラー時の引数は上記の通り` SqlError $error, ?Ecxeption $trace ` となります。` SqlError ` については[ SqlError] ( https://github.com/poggit/libasynql/blob/master/libasynql/src/poggit/libasynql/SqlError.php ) を参照してください。
64+ ` $raws[<int>] ` に格納されているデータは基本的に` accounts ` の` name ` カラムとそれぞれのテーブルのカラムを複合したものになります。`
0 commit comments