- Custom DataBase Tables
- CDBT Version 2.x
- メソッド・リファレンス
- get_table_status
get_table_status
(CDBT 2.0.0)
get_table_status指定テーブルのテーブル・ステータスを取得します
Description
mixed get_table_status ( string $table_name [, mixed $state_name ] )指定テーブルのテーブル・ステータスを取得します。テーブル・ステータスが取得できた場合、
get_table_status()はテーブル・ステータスの配列を返します。ただし、state_nameに単一のステータス名を指定した場合は合致したステータスの文字列が返ります。Parameters
- table_name
- テーブル・ステータスを取得したいテーブル名。
- state_name
- 取得したいステータス名。複数のステータスを取得したい場合は、ステータス名の配列で指定します。
取得可能なステータス名:
- Name ─ テーブル名(データベース・システムとしての物理名)
- Engine ─ データベース・エンジン
- Version ─ データベースのバージョン
- Row_format ─ 列のフォーマット
- Rows ─ 現在のレコード数(列数)
- Avg_row_length ─ 平均レコードサイズ
- Data_length ─ 総データサイズ
- Max_data_length ─ 最大データサイズ
- Index_length ─ インデックスのサイズ
- Data_free ─ 空き領域の容量
- Auto_increment ─ 現在の自動採番キー(サロゲートキー)の最終番号
- Create_time ─ テーブル作成日時
- Update_time ─ テーブル更新日時
- Check_time ─ チェックサム実行日時
- Collation ─ データ照合順の文字コード
- Checksum ─ チェックサムが有効かどうか
- Create_options ─ テーブル作成時のオプション
- Comment ─ テーブル・コメント
Return
state_nameが省略された場合、指定したテーブルのテーブル・ステータスを配列として返します。state_nameが指定されている場合で、合致するステータス名が存在していれば、state_nameが配列で指定されていれば配列が返り、state_nameが文字列で指定されていれば文字列が返ります。
なお、state_nameに合致するステータスが存在していない場合はFALSEが返ります。
History
| バージョン | 内容 |
|---|---|
| 2.0.0 | 新規追加 |
Example
例1 すべてのテーブル・ステータスを取得する
<?php
global $cdbt;
$table_name = "prefix_table";
if ( $table_status = $cdbt->get_table_status( $table_name ) ) {
print_r( $table_status );
}
例2 特定のテーブル・ステータスを取得する
<?php
global $cdbt;
$table_name = "prefix_table";
if ( $table_status = $cdbt->get_table_status( $table_name, [ 'Name', 'Engine', 'Rows' ] ) ) {
print_r( $table_status );
}
例3 単一のテーブル・ステータスを取得する
<?php
global $cdbt;
$table_name = "prefix_table";
$table_comment = $cdbt->get_table_status( $table_name, 'Comment' );
上記の例のようにテーブル・コメントのみを取得する場合だけは、ラッパーのメソッドとしてget_table_comment()が利用できます。
Reference
Related Methods
- get_table_comment()テーブルのコメントを取得します