pg_field_prtlen
(PHP 4 >= 4.2.0, PHP 5, PHP 7)
pg_field_prtlen - 返回打印的长度
描述
int pg_field_prtlen ( resource $result , int $row_number , mixed $field_name_or_number )
int pg_field_prtlen ( resource $result , mixed $field_name_or_number )
pg_field_prtlen()返回PostgreSQL中特定值的实际打印长度(字符数)result
。行编号从0开始。此函数将返回FALSE
一个错误。
field_name_or_number
可以作为整数或字符串传递。如果以整数形式传递,PHP会将其识别为字段编号,否则将其视为字段名称。
请参阅pg_field_name()页面中给出的示例。
注意:这个函数被称为pg_fieldprtlen()。
参数
result
PostgreSQL查询结果资源,由pg_query(),pg_query_params()或pg_execute()等返回。
row
结果中的行号。行从0开始编号。如果省略,则取出当前行。
返回值
该字段打印长度或FALSE
错误。
例子
Example #1 Getting information about fields
<?php
??$dbconn?=?pg_connect("dbname=publisher")?or?die("Could?not?connect");
??$res?=?pg_query($dbconn,?"select?*?from?authors?where?author?=?'Orwell'");
??$i?=?pg_num_fields($res);
??for?($j?=?0;?$j?<?$i;?$j++)?{
??????echo?"column?$j\n";
??????$fieldname?=?pg_field_name($res,?$j);
??????echo?"fieldname:?$fieldname\n";
??????echo?"printed?length:?"?.?pg_field_prtlen($res,?$fieldname)?.?"?characters\n";
??????echo?"storage?length:?"?.?pg_field_size($res,?$j)?.?"?bytes\n";
??????echo?"field?type:?"?.?pg_field_type($res,?$j)?.?"?\n\n";
??}
?>
上面的例子将输出:
column 0
fieldname: author
printed length: 6 characters
storage length: -1 bytes
field type: varchar
column 1
fieldname: year
printed length: 4 characters
storage length: 2 bytes
field type: int2
column 2
fieldname: title
printed length: 24 characters
storage length: -1 bytes
field type: varchar
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com