Thanks Cris!
I've fixed the manual.
Nuno
----- Original Message -----
> From having a look in the source, and more pain with
> pgsql than anyone should be subjected to, I think
> what's happening is a cross-confusion of two issues.
>
> You're right in that if you call it with three
> parameters the validation equates to your
> interpretation, not his, and the column can be
> specified as either string (name) or long (number).
>
> Where *he's* going wrong is in dealing with pgsql's
> case-handling. Postgres will lower-case all column
> names by default, *unless* you wrap them in quotes
> when you create the table to preserve the casing. This
> means that you have to wrap the column names in quotes
> (to preserve the casing) in *every damn statement /
> query* you make to that table thereafter. What he's
> doing is initialising the column name *directly* with
> the return value of another query, but not wrapping it
> in escaped quotes, so postgres is treating the
> $fieldname in the later pg_field_prtlen() call as
> 'second_column' and not '"Second_Column"'. Basically:
> it's a combination of a postgres issue and his code. I
> think. :)
>
> Cris
>
> >
> > > 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:<br>\n";
> > > $fieldname = pg_field_name($result, 0);
> > > echo "fieldname: $fieldname <br>\n";
> > > $fieldlength = pg_field_prtlen($result, 0, 0);
> > > echo "fieldlength: $fieldlength <br>\n";
> > > $fieldlength2 = pg_field_prtlen($result, 0,
> > $fieldname);
> > > echo "fieldlength: $fieldlength2 <br>\n";
> > >
> > > echo '<br>table column index 1, has a mixed
> > case name, generates
> > > e_notice and empty fieldlength:<br>\n';
> > > $fieldname = pg_field_name($result, 1);
> > > echo "fieldname: $fieldname <br>\n";
> > > $fieldlength3 = pg_field_prtlen($result, 0,
> > 1);
> > > echo "fieldlength: $fieldlength3 <br>\n";
> > > $fieldlength4 = pg_field_prtlen($result, 0,
> > $fieldname);
> > > echo "fieldlength: $fieldlength4 <br>\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] [EMAIL PROTECTED]
> > >
> > > 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.
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php