Re: Inquiry From Form [pgsql]

From: Budi Rianto <brianto(at)freenet(dot)de>
To: pgsql-php(at)postgresql(dot)org
Subject: Re: Inquiry From Form [pgsql]
Date: 2002-11-18 04:48:41
Message-ID: 200211181148.57873.brianto@freenet.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sunday 17 November 2002 05:43 pm, you wrote:
> On Fri, 15 Nov 2002, William wrote:
> > I code with PHP and use it to communicate with MySQL, if I started using
> > PostgreSQL would I have to change my coding to communicate with the
> > database?
>
> Probably, but only slightly.
>
> I changed my DB from MySQL to PostgreSQL and had to change each SQL call
> slightly. It seems to me the difference was PostgreSQL needs to know the
> number of rows gotten and then loop through them with a for loop, with
> MySQL I was able to use a while loop without checking the number of rows
> first.
>
[snip]

Using PostgreSQL 7.2 and PHP 4.1.2 in Linux, I found that some code is
becoming similar with the MySQL+PHP. For instance, you don't need to know the
numrows first to do a loop that display a query result.

New PostgreSQL+PHP way:

while($display=pg_fetch_array($getquery))
{
...
}

MySQL way :
while($display=mysql_fetch_array($getquery))
{
...
}

You can also use pg_numrows() instead of pg_num_rows() and some other 'new'
syntax that are like mysql way.

HTH
Budi.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE92HE1ZVSaxFm5xCIRAr1pAKCTnSD+hUoXe3+L+XXDONwhne49uACgtkGZ
CsVGw+0Y9nji8MZj8D50e7s=
=3lBF
-----END PGP SIGNATURE-----

In response to

Browse pgsql-php by date

  From Date Subject
Next Message Andy Dunlop 2002-11-18 07:06:05 Nested select to same tsble
Previous Message brew 2002-11-17 10:43:16 Inquiry From Form [pgsql]