PHP Conference Japan 2024

cubrid_field_flags

(PECL CUBRID >= 8.3.0)

cubrid_field_flags傳回指定欄位偏移量的旗標字串

說明

cubrid_field_flags(resource $result, int $field_offset): string

此函式會傳回一個字串,其中包含以空格分隔的指定欄位偏移量的旗標。您可以使用 explode 來分割傳回值。可能的旗標包括:not_nullprimary_keyunique_keyforeign_keyauto_incrementsharedreverse_indexreverse_uniquetimestamp

參數

result

result 參數來自 cubrid_execute() 的呼叫結果。

field_offset

欄位偏移量的數值。 field_offset 從 0 開始。如果 field_offset 不存在,也會發出等級為 E_WARNING 的錯誤。

回傳值

處理成功時,會回傳帶有標記的字串。

當 field_offset 值無效時,回傳 false

如果 SQL 語句不是 SELECT,則回傳 -1。

範例

範例 #1 cubrid_field_flags() 範例

<?php
$conn
= cubrid_connect("localhost", 33000, "demodb");
$result = cubrid_execute($conn, "SELECT * FROM game WHERE host_year=2004 AND nation_code='AUS' AND medal='G'");

$col_num = cubrid_num_cols($result);

printf("%-30s %s\n", "欄位名稱", "欄位標記");
for(
$i = 0; $i < $col_num; $i++) {
printf("%-30s %s\n", cubrid_field_name($result, $i), cubrid_field_flags($result, $i));
}

cubrid_disconnect($conn);
?>

以上範例將輸出

Field Name                     Field Flags
host_year                      not_null primary_key unique_key
event_code                     not_null primary_key unique_key foreign_key
athlete_code                   not_null primary_key unique_key foreign_key
stadium_code                   not_null
nation_code                    
medal                          
game_date
新增註解

使用者貢獻的註解

此頁面沒有使用者貢獻的註解。
To Top