using pg_fieldisnull

Поиск
Список
Период
Сортировка
Искать

using pg_fieldisnull

От:
"Christopher Smith" <csmith@gio.com.au>
Дата:


Hi all,

Just wondering if anyone can give me some examples on how to use pg_fieldisnull.
This is the reason why.. Currently I have this loop set up to get all data from
a database (I'm just doing a simple one at the moment until I can teach myself
some more :)..). I figure there's a lot better way to do this using
pg_fieldisnull or some other means.

$numrows = pg_numrows($result);
$row=0;
printf ("\n");
printf ("\n");
do
{
  $myrow = pg_fetch_row ($result,$row);
  printf ("\n", $myrow[0], $myrow[1],
$myrow[2]);
  $row++;
}
while ($row < $numrows);

it doesn't nescessarily have to put it into a table, so formatting it isn't a
problem.  Any suggestions? I know there's a better way to do this, but I can't
think of it :(
I'm using pgsql6.5.3 and php4.

Thanks,
Chris.


IDFirst NameSurname
%s%s%s

Re: using pg_fieldisnull

От:
Andrew McMillan <Andrew@catalyst.net.nz>
Дата:
Christopher Smith wrote:
> 
> Hi all,
> 
> Just wondering if anyone can give me some examples on how to use pg_fieldisnull.
> This is the reason why.. Currently I have this loop set up to get all data from
> a database (I'm just doing a simple one at the moment until I can teach myself
> some more :)..). I figure there's a lot better way to do this using
> pg_fieldisnull or some other means.

I haven't neede to use pg_fieldisnull at all myself, but here's how I
would code the loop you use...

$numrows = pg_numrows($result);
if ( $numrows > 0 ) echo "\n";

for ( $row=0; $row < $numrows; $row++ ) {
  $person = pg_Fetch_Object( $result, $row );
  echo
"\n";
}
if ( $numrows > 0 ) echo "
IDFirst NameSurname
$person->id$person->firstname$person->surname
\n"; > > $numrows = pg_numrows($result); > $row=0; > printf ("\n"); > printf ("\n"); > do > { > $myrow = pg_fetch_row ($result,$row); > printf ("\n", $myrow[0], $myrow[1], > $myrow[2]); > $row++; > } > while ($row < $numrows); > > it doesn't nescessarily have to put it into a table, so formatting it isn't a > problem. Any suggestions? I know there's a better way to do this, but I can't > think of it :( > I'm using pgsql6.5.3 and php4. As I said, I'm not sure why you need to know if one of the fields is null, but I have found the above style of PHP coding much more re-readable in general. Especially the use of field names rather than arrays for the returned record. Cheers, Andrew. -- _____________________________________________________________________ Andrew McMillan, e-mail: Andrew@cat-it.co.nz Catalyst IT Ltd, PO Box 10-225, Level 22, 105 The Terrace, Wellington Me: +64 (21) 635 694, Fax: +64 (4) 499 5596, Office: +64 (4) 499 2267
IDFirst NameSurname
%s%s%s
FAQ