Re: psql with PHP question

From: "Adam Lang" <aalang(at)rutgersinsurance(dot)com>
To: <pgsql-php(at)postgresql(dot)org>
Subject: Re: psql with PHP question
Date: 2001-05-03 13:05:38
Message-ID: 008b01c0d3d1$bfe11a00$330a0a0a@rutgersinsurance.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice pgsql-php

First off, cross-posting is rude. Don't post to more than one list at a
time. Post your question to the most relevant list first and if you don't
get help, then try another one.

As for your select statement, why do you have the select around the other
select? Why don't you just have this:

SELECT MAX(id) FROM article

As for how the result is returned, not much you can do about it. That is
the way PHP is. As a matter of fact, that is the way a vast majority of
database interaction programs are. They send an array so that the field
name can accompany it.

Only optimization you can do is fix the select statement.

Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company
http://www.rutgersinsurance.com
----- Original Message -----
From: "Jason" <gee308(at)mediaone(dot)net>
To: <pgsql-php(at)postgresql(dot)org>
Cc: <pgsql-novice(at)postgresql(dot)org>; <pgsql-general(at)postgresql(dot)org>
Sent: Thursday, May 03, 2001 8:06 AM
Subject: [PHP] psql with PHP question

> Hi, I want to try and optimize my calls to postgreSQL from PHP. If
> I only need one field from a select statement, what should I use? I am
> currently using:
> $q = pg_Exec("SELECT id FROM article WHERE id=(SELECT MAX(id)
> FROM article)");
> $maxid = pg_fetch_array($q, 0);
> echo "The highest id is ". $maxid[0];
> What can I use besides an array to get a single value? In general, using
> a single variable always saves more memory than using an array? Thank
> you.
> Jason
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-05-03 13:27:22 Re: Problems compiling 7.1 with TCL support on Solaris 7
Previous Message Chris Ryan 2001-05-03 12:54:58 Re: [NOVICE] psql with PHP question

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2001-05-03 13:27:22 Re: Problems compiling 7.1 with TCL support on Solaris 7
Previous Message Chris Ryan 2001-05-03 12:54:58 Re: [NOVICE] psql with PHP question

Browse pgsql-php by date

  From Date Subject
Next Message Tom Lane 2001-05-03 13:27:22 Re: Problems compiling 7.1 with TCL support on Solaris 7
Previous Message Chris Ryan 2001-05-03 12:54:58 Re: [NOVICE] psql with PHP question