(PECL PDO_CUBRID >= 8.3.0.0001)
PDO::cubrid_schema — 获取请求的模式信息
此函数用于从数据库获取请求的模式信息。您必须指定 table_name
,如果您想获取有关特定表的的信息,col_name
,如果您想获取有关特定列的信息(仅可与 PDO::CUBRID_SCH_COL_PRIVILEGE 一起使用)。
此函数的结果将作为二维数组返回(列(关联数组) * 行(数字数组))。下表显示了模式类型以及基于模式类型将返回的结果数组的列结构。
模式 | 列号 | 列名 | 值 |
---|---|---|---|
PDO::CUBRID_SCH_TABLE | 1 | NAME | |
2 | TYPE | 0:系统表 1:视图 2:表 | |
PDO::CUBRID_SCH_VIEW | 1 | NAME | |
2 | TYPE | 1:视图 | |
PDO::CUBRID_SCH_QUERY_SPEC | 1 | QUERY_SPEC | |
PDO::CUBRID_SCH_ATTRIBUTE / PDO::CUBRID_SCH_TABLE_ATTRIBUTE | 1 | ATTR_NAME | |
2 | DOMAIN | ||
3 | SCALE | ||
4 | PRECISION | ||
5 | INDEXED | 1:已索引 | |
6 | NOT NULL | 1:非空 | |
7 | SHARED | 1:共享 | |
8 | UNIQUE | 1:唯一 | |
9 | DEFAULT | ||
10 | ATTR_ORDER | base:1 | |
11 | CLASS_NAME | ||
12 | SOURCE_CLASS | ||
13 | IS_KEY | 1:键 | |
PDO::CUBRID_SCH_METHOD / PDO::CUBRID_SCH_TABLE_METHOD | 1 | NAME | |
2 | RET_DOMAIN | ||
3 | ARG_DOMAIN | ||
PDO::CUBRID_SCH_METHOD_FILE | 1 | METHOD_FILE | |
PDO::CUBRID_SCH_SUPER_TABLE / PDO::CUBRID_SCH_DIRECT_SUPER_TABLE / PDO::CUBRID_SCH_SUB_TABLE | 1 | CLASS_NAME | |
2 | TYPE | 0:系统表 1:视图 2:表 | |
PDO::CUBRID_SCH_CONSTRAINT | 1 | TYPE | 0:唯一 1:索引 2:反向唯一 3:反向索引 |
2 | NAME | ||
3 | ATTR_NAME | ||
4 | NUM_PAGES | ||
5 | NUM_KEYS | ||
6 | PRIMARY_KEY | 1:主键 | |
7 | KEY_ORDER | base:1 | |
PDO::CUBRID_SCH_TRIGGER | 1 | NAME | |
2 | STATUS | ||
3 | EVENT | ||
4 | TARGET_CLASS | ||
5 | TARGET_ATTR | ||
6 | ACTION_TIME | ||
7 | ACTION | ||
8 | PRIORITY | ||
9 | CONDITION_TIME | ||
10 | CONDITION | ||
PDO::CUBRID_SCH_TABLE_PRIVILEGE / PDO::CUBRID_SCH_COL_PRIVILEGE | 1 | CLASS_NAME / ATTR_NAME | |
2 | PRIVILEGE | ||
3 | GRANTABLE | ||
PDO::CUBRID_SCH_PRIMARY_KEY | 1 | CLASS_NAME | |
2 | ATTR_NAME | ||
3 | KEY_SEQ | base:1 | |
4 | KEY_NAME | ||
PDO::CUBRID_SCH_IMPORTED_KEYS / PDO::CUBRID_SCH_EXPORTED_KEYS / PDO::CUBRID_SCH_CROSS_REFERENCE | 1 | PKTABLE_NAME | |
2 | PKCOLUMN_NAME | ||
3 | FKTABLE_NAME | base:1 | |
4 | FKCOLUMN_NAME | ||
5 | KEY_SEQ | base:1 | |
6 | UPDATE_ACTION | 0:级联 1:限制 2:无操作 3:设为空 | |
7 | DELETE_ACTION | 0:级联 1:限制 2:无操作 3:设为空 | |
8 | FK_NAME | ||
9 | PK_NAME |
schema_type
您想要了解的模式类型。
table_name
您想了解其模式的表。
col_name
您想了解其模式的列。
包含模式信息的数组,当进程成功时;
FALSE,当进程不成功时
示例 #1 一个 PDO::cubrid_schema() 示例
此示例演示如何获取表 game 的主键和外键。
<?php
$pk_list = $dbh->cubrid_schema(PDO::CUBRID_SCH_PRIMARY_KEY, "game");
print_r($pk_list);
$fk_list = $dbh->cubrid_schema(PDO::CUBRID_SCH_IMPORTED_KEYS, "game");
print_r($fk_list);
?>
以上示例将输出
Result: Array ( [0] => Array ( [CLASS_NAME] => game [ATTR_NAME] => athlete_code [KEY_SEQ] => 3 [KEY_NAME] => pk_game_host_year_event_code_athlete_code ) [1] => Array ( [CLASS_NAME] => game [ATTR_NAME] => event_code [KEY_SEQ] => 2 [KEY_NAME] => pk_game_host_year_event_code_athlete_code ) [2] => Array ( [CLASS_NAME] => game [ATTR_NAME] => host_year [KEY_SEQ] => 1 [KEY_NAME] => pk_game_host_year_event_code_athlete_code ) ) Array ( [0] => Array ( [PKTABLE_NAME] => athlete [PKCOLUMN_NAME] => code [FKTABLE_NAME] => game [FKCOLUMN_NAME] => athlete_code [KEY_SEQ] => 1 [UPDATE_RULE] => 1 [DELETE_RULE] => 1 [FK_NAME] => fk_game_athlete_code [PK_NAME] => pk_athlete_code ) [1] => Array ( [PKTABLE_NAME] => event [PKCOLUMN_NAME] => code [FKTABLE_NAME] => game [FKCOLUMN_NAME] => event_code [KEY_SEQ] => 1 [UPDATE_RULE] => 1 [DELETE_RULE] => 1 [FK_NAME] => fk_game_event_code [PK_NAME] => pk_event_code ) )