(PECL CUBRID >= 8.3.1)
cubrid_fetch_field — 从结果中获取列信息并以对象形式返回
此函数返回一个包含特定列某些属性的对象。对象的属性为
name
列名
table
该列所属表的名称
def
该列的默认值
max_length
该列的最大长度
not_null
如果该列不能为 NULL,则为 1
primary_key
如果该列为主键,则为 1
unique_key
如果该列为唯一键,则为 1
multiple_key
如果该列为非唯一键,则为 1
numeric
如果该列为数值,则为 1
blob
如果该列为 BLOB,则为 1
type
该列的类型
unsigned
如果该列为无符号,则为 1
zerofill
如果该列为零填充,则为 1
result
result
来自对 cubrid_execute() 的调用
field_offset
数值字段偏移量。如果未指定字段偏移量,则检索下一个(尚未由此函数检索的)字段。 field_offset
从 0 开始。
示例 #1 cubrid_fetch_field() 示例
<?php
$conn = cubrid_connect("localhost", 33000, "demodb");
$req = cubrid_execute($conn, "SELECT event_code,athlete_code,nation_code,game_date FROM game WHERE host_year=1988 and event_code=20001;");
var_dump(cubrid_fetch_row($req));
cubrid_field_seek($req, 1);
$field = cubrid_fetch_field($req);
printf("\n--- Field Properties ---\n");
printf("%-30s %s\n", "name:", $field->name);
printf("%-30s %s\n", "table:", $field->table);
printf("%-30s \"%s\"\n", "default value:", $field->def);
printf("%-30s %d\n", "max length:", $field->max_length);
printf("%-30s %d\n", "not null:", $field->not_null);
printf("%-30s %d\n", "primary key:", $field->primary_key);
printf("%-30s %d\n", "unique key:", $field->unique_key);
printf("%-30s %d\n", "multiple key:", $field->multiple_key);
printf("%-30s %d\n", "numeric:", $field->numeric);
printf("%-30s %d\n", "blob:", $field->blob);
printf("%-30s %s\n", "type:", $field->type);
printf("%-30s %d\n", "unsigned:", $field->unsigned);
printf("%-30s %d\n", "zerofill:", $field->zerofill);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
上面的示例将输出
array(4) { [0]=> string(5) "20001" [1]=> string(5) "16681" [2]=> string(3) "KOR" [3]=> string(9) "1988-9-30" } --- Field Properties --- name: athlete_code table: game default value: "" max length: 0 not null: 1 primary key: 1 unique key: 1 multiple key: 0 numeric: 1 blob: 0 type: integer unsigned: 0 zerofill: 0