Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10885 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26295 invoked by uid 1010); 3 Jul 2004 11:05:39 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 26263 invoked from network); 3 Jul 2004 11:05:38 -0000 Received: from unknown (HELO sapo.pt) (212.55.154.26) by pb1.pair.com with SMTP; 3 Jul 2004 11:05:38 -0000 Received: (qmail 10084 invoked from network); 3 Jul 2004 11:05:37 -0000 Received: from unknown (HELO sapo.pt) (10.134.35.155) by relay6 with SMTP; 3 Jul 2004 11:05:37 -0000 Received: (qmail 11178 invoked from network); 3 Jul 2004 11:04:24 -0000 Received: from unknown (HELO pc07653) (nunoplopes@sapo.pt@[81.193.138.159]) (envelope-sender ) by mta5 (qmail-ldap-1.03) with SMTP for ; 3 Jul 2004 11:04:24 -0000 Message-ID: <007401c460ee$5df644c0$0100a8c0@pc07653> To: "PHPdev" Date: Sat, 3 Jul 2004 12:10:36 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Subject: Fw: [PHP-DOC] #28994 [Opn]: pg_field_prtlen takes int instead of string as third argument From: nlopess@php.net ("Nuno Lopes") Can anybody take a look into this, please? Thanks, Nuno > ID: 28994 > User updated by: bas at vanklinkenbergsoftware dot nl > Reported By: bas at vanklinkenbergsoftware dot nl > Status: Open > Bug Type: Documentation problem > Operating System: N/A > PHP Version: 4.3.7 > New Comment: > > All right, some more investigation shows me that when using lower case > column names, all works well. When using mixed case column names, using > a string as the third argument generates the 'Bad Column Offset' error. > See code snippet below. Note that fieldnames are correctly retrieved > with pg_field_name(). > > $db_conn = pg_connect("host = localhost port = 5432 dbname = test > user = test password = test"); > $result = pg_query($db_conn, 'SELECT * FROM test'); > echo "table column index 0, has a lower case name, works > fine:
\n"; > $fieldname = pg_field_name($result, 0); > echo "fieldname: $fieldname
\n"; > $fieldlength = pg_field_prtlen($result, 0, 0); > echo "fieldlength: $fieldlength
\n"; > $fieldlength2 = pg_field_prtlen($result, 0, $fieldname); > echo "fieldlength: $fieldlength2
\n"; > > echo '
table column index 1, has a mixed case name, generates > e_notice and empty fieldlength:
\n'; > $fieldname = pg_field_name($result, 1); > echo "fieldname: $fieldname
\n"; > $fieldlength3 = pg_field_prtlen($result, 0, 1); > echo "fieldlength: $fieldlength3
\n"; > $fieldlength4 = pg_field_prtlen($result, 0, $fieldname); > echo "fieldlength: $fieldlength4
\n"; > > You can test the code above at this url: > http://212.61.21.72/test/pg_field_prtlen_test.php > > The database table used in the above code looks like this: > ============== > Welcome to psql 7.3.4-RH, the PostgreSQL interactive terminal. > > You are now connected to database test as user test. > test=> select * from test; > first_column | Second_Column > --------------+---------------- > 1 | some text > 2 | some more text > (2 rows) > > test=> > ============ > > Appearantly it looks like there are two problems: the documentation > problem, where the possibility to pass an int as the third argument is > not documented, and the error that occurs when using mixed case column > names. Should I file the latter as a separate bug? > > Regards, > Bas > > > Previous Comments: > ------------------------------------------------------------------------ > > [2004-07-02 23:17:01] nlopess@php.net > > What I can see in the sources is that the proto is: > > int pg_field_prtlen(resource result, [int row,] mixed > field_name_or_number > > > Row is optional and the last parameter can be either a string or an > integer. If it's passed as string, it is recongnised as the field name, > otherwise as the field number. > > I've never used PostgreSQL, so can you or somebody confirm if the > function is behaving as I've stated, please?? > > Thanks, > Nuno > > ------------------------------------------------------------------------ > > [2004-07-02 15:50:02] bas at vanklinkenbergsoftware dot nl > > Description: > ------------ > In the online documentation for pg_field_prtlen, the function > arguments are described as follows: > > int pg_field_prtlen (resource result, int row_number, string > field_name) > > but actually it should be: > > int pg_field_prtlen (resource result, int row_number, int > column_number) > > (The third argument should be column number instead of field name). > When using pg_field_prtlen as stated in the online documentation, a > 'Bad Column Offset' error is generated. > > > > ------------------------------------------------------------------------ > > Edit this bug report at http://bugs.php.net/?id=28994&edit=1