PHP: Hypertext Preprocessor (original) (raw)
cubrid_schema
(PECL CUBRID >= 8.3.0)
cubrid_schema — Get the requested schema information
Description
cubrid_schema(
resource $conn_identifier
,
int $schema_type
,
string $class_name
= ?,
string $attr_name
= ?
): array
The result of the cubrid_schema() function is returned as a two-dimensional array (column (associative array) * row (numeric array)). The following tables shows types of schema and the column structure of the result array to be returned based on the schema type.
Result Composition of Each Type
Schema | Column Number | Column Name | Value |
---|---|---|---|
CUBRID_SCH_CLASS | 1 | NAME | |
2 | TYPE | 0:system class 1:vclass 2:class | |
CUBRID_SCH_VCLASS | 1 | NAME | |
2 | TYPE | 1:vclass | |
CUBRID_SCH_QUERY_SPEC | 1 | QUERY_SPEC | |
CUBRID_SCH_ATTRIBUTE / CUBRID_SCH_CLASS_ATTRIBUTE | 1 | ATTR_NAME | |
2 | DOMAIN | ||
3 | SCALE | ||
4 | PRECISION | ||
5 | INDEXED | 1:indexed | |
6 | NOT NULL | 1:not null | |
7 | SHARED | 1:shared | |
8 | UNIQUE | 1:unique | |
9 | DEFAULT | ||
10 | ATTR_ORDER | base:1 | |
11 | CLASS_NAME | ||
12 | SOURCE_CLASS | ||
13 | IS_KEY | 1:key | |
CUBRID_SCH_METHOD / CUBRID_SCH_CLASS_METHOD | 1 | NAME | |
2 | RET_DOMAIN | ||
3 | ARG_DOMAIN | ||
CUBRID_SCH_METHOD_FILE | 1 | METHOD_FILE | |
CUBRID_SCH_SUPERCLASS / CUBRID_SCH_DIRECT_SUPER_CLASS / CUBRID_SCH_SUBCLASS | 1 | CLASS_NAME | |
2 | TYPE | 0:system class 1:vclass 2:class | |
CUBRID_SCH_CONSTRAINT | 1 | TYPE | 0:unique 1:index 2:reverse unique 3:reverse index |
2 | NAME | ||
3 | ATTR_NAME | ||
4 | NUM_PAGES | ||
5 | NUM_KEYS | ||
6 | PRIMARY_KEY | 1:primary key | |
7 | KEY_ORDER | base:1 | |
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 | ||
CUBRID_SCH_CLASS_PRIVILEGE / CUBRID_SCH_ATTR_PRIVILEGE | 1 | CLASS_NAME / ATTR_NAME | |
2 | PRIVILEGE | ||
3 | GRANTABLE | ||
CUBRID_SCH_PRIMARY_KEY | 1 | CLASS_NAME | |
2 | ATTR_NAME | ||
3 | KEY_SEQ | base:1 | |
4 | KEY_NAME | ||
CUBRID_SCH_IMPORTED_KEYS / CUBRID_SCH_EXPORTED_KEYS / 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:cascade 1:restrict 2:no action 3:set null | |
7 | DELETE_ACTION | 0:cascade 1:restrict 2:no action 3:set null | |
8 | FK_NAME | ||
9 | PK_NAME |
Parameters
conn_identifier
Connection identifier.
schema_type
Schema data that you want to know.
class_name
Class you want to know the schema of.
attr_name
Attribute you want to know the schema of.
Return Values
Array containing the schema information, when process is successful, or [false](reserved.constants.php#constant.false)
on failure.
Changelog
Version | Description |
---|---|
8.3.1 | Change return value: when process is unsuccessful, return false, not -1. |
Examples
Example #1 cubrid_schema() example
<?php $conn = cubrid_connect("localhost", 33000, "demodb", "dba");printf("\n--- Primary Key ---\n"); <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mi>k</mi><mo>=</mo><mi>c</mi><mi>u</mi><mi>b</mi><mi>r</mi><mi>i</mi><msub><mi>d</mi><mi>s</mi></msub><mi>c</mi><mi>h</mi><mi>e</mi><mi>m</mi><mi>a</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">pk = cubrid_schema(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">c</span><span class="mord mathnormal">u</span><span class="mord mathnormal">b</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">i</span><span class="mord"><span class="mord mathnormal">d</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">s</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">c</span><span class="mord mathnormal">h</span><span class="mord mathnormal">e</span><span class="mord mathnormal">ma</span><span class="mopen">(</span></span></span></span>conn, CUBRID_SCH_PRIMARY_KEY, "game"); var_dump($pk);printf("\n--- Foreign Keys ---\n"); <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>f</mi><mi>k</mi><mo>=</mo><mi>c</mi><mi>u</mi><mi>b</mi><mi>r</mi><mi>i</mi><msub><mi>d</mi><mi>s</mi></msub><mi>c</mi><mi>h</mi><mi>e</mi><mi>m</mi><mi>a</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">fk = cubrid_schema(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">c</span><span class="mord mathnormal">u</span><span class="mord mathnormal">b</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">i</span><span class="mord"><span class="mord mathnormal">d</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">s</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">c</span><span class="mord mathnormal">h</span><span class="mord mathnormal">e</span><span class="mord mathnormal">ma</span><span class="mopen">(</span></span></span></span>conn, CUBRID_SCH_IMPORTED_KEYS, "game"); var_dump($fk);printf("\n--- Column Attribute ---\n"); <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mi>t</mi><mi>t</mi><mi>r</mi><mo>=</mo><mi>c</mi><mi>u</mi><mi>b</mi><mi>r</mi><mi>i</mi><msub><mi>d</mi><mi>s</mi></msub><mi>c</mi><mi>h</mi><mi>e</mi><mi>m</mi><mi>a</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">attr = cubrid_schema(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord mathnormal">a</span><span class="mord mathnormal">tt</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">c</span><span class="mord mathnormal">u</span><span class="mord mathnormal">b</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">i</span><span class="mord"><span class="mord mathnormal">d</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">s</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">c</span><span class="mord mathnormal">h</span><span class="mord mathnormal">e</span><span class="mord mathnormal">ma</span><span class="mopen">(</span></span></span></span>conn, CUBRID_SCH_ATTRIBUTE, "stadium", "area"); var_dump($attr);cubrid_disconnect($conn); ?>
The above example will output:
--- Primary Key --- array(3) { [0]=> array(4) { ["CLASS_NAME"]=> string(4) "game" ["ATTR_NAME"]=> string(12) "athlete_code" ["KEY_SEQ"]=> string(1) "3" ["KEY_NAME"]=> string(41) "pk_game_host_year_event_code_athlete_code" } [1]=> array(4) { ["CLASS_NAME"]=> string(4) "game" ["ATTR_NAME"]=> string(10) "event_code" ["KEY_SEQ"]=> string(1) "2" ["KEY_NAME"]=> string(41) "pk_game_host_year_event_code_athlete_code" } [2]=> array(4) { ["CLASS_NAME"]=> string(4) "game" ["ATTR_NAME"]=> string(9) "host_year" ["KEY_SEQ"]=> string(1) "1" ["KEY_NAME"]=> string(41) "pk_game_host_year_event_code_athlete_code" } }
--- Foreign Keys --- array(2) { [0]=> array(9) { ["PKTABLE_NAME"]=> string(7) "athlete" ["PKCOLUMN_NAME"]=> string(4) "code" ["FKTABLE_NAME"]=> string(4) "game" ["FKCOLUMN_NAME"]=> string(12) "athlete_code" ["KEY_SEQ"]=> string(1) "1" ["UPDATE_RULE"]=> string(1) "1" ["DELETE_RULE"]=> string(1) "1" ["FK_NAME"]=> string(20) "fk_game_athlete_code" ["PK_NAME"]=> string(15) "pk_athlete_code" } [1]=> array(9) { ["PKTABLE_NAME"]=> string(5) "event" ["PKCOLUMN_NAME"]=> string(4) "code" ["FKTABLE_NAME"]=> string(4) "game" ["FKCOLUMN_NAME"]=> string(10) "event_code" ["KEY_SEQ"]=> string(1) "1" ["UPDATE_RULE"]=> string(1) "1" ["DELETE_RULE"]=> string(1) "1" ["FK_NAME"]=> string(18) "fk_game_event_code" ["PK_NAME"]=> string(13) "pk_event_code" } }
--- Column Attribute --- array(1) { [0]=> array(13) { ["ATTR_NAME"]=> string(4) "area" ["DOMAIN"]=> string(1) "7" ["SCALE"]=> string(1) "2" ["PRECISION"]=> string(2) "10" ["INDEXED"]=> string(1) "0" ["NON_NULL"]=> string(1) "0" ["SHARED"]=> string(1) "0" ["UNIQUE"]=> string(1) "0" ["DEFAULT"]=> NULL ["ATTR_ORDER"]=> string(1) "4" ["CLASS_NAME"]=> string(7) "stadium" ["SOURCE_CLASS"]=> string(7) "stadium" ["IS_KEY"]=> string(1) "0" } }
Found A Problem?
There are no user contributed notes for this page.