Thread: varchar length... PHP

varchar length... PHP

From
Constantin Khatsckevich
Date:
Hello!

Can I get ordered length of the varchar field? I need it in PHP script.

For example,
CREATE TABLE t1
(
   id int,
   str varchar(40)
);

PHP function pg_FieldSize() returns me -1 for field str, because this is
variable length field, but I need got 40 (in the my example). May be
like sizeof() ?????


--
Best regards,
Constantin Khatskevich.


Re: varchar length... PHP

From
mike g
Date:
Hello,

Varchar by default will truncate extra space at the end.  If the table
column is defined as char or you cast the varchar to a char data type it
will have a fixed size of 40 characters.

Mike

On Tue, 2004-07-13 at 06:29, Constantin Khatsckevich wrote:
> Hello!
>
> Can I get ordered length of the varchar field? I need it in PHP script.
>
> For example,
> CREATE TABLE t1
> (
>    id int,
>    str varchar(40)
> );
>
> PHP function pg_FieldSize() returns me -1 for field str, because this is
> variable length field, but I need got 40 (in the my example). May be
> like sizeof() ?????
>