pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adam Lang <aalang@rutgersinsurance.com>
To: pgsql-php@postgresql.org
Subject: Re: psql with PHP question
Date: Thu, 3 May 2001 09:05:38 -0400
Message-ID: <008b01c0d3d1$bfe11a00$330a0a0a@rutgersinsurance.com> (raw)
References: <3AF1427C.B4E85A45@is3-design.com>
	<3AF149C1.AEC30AA9@mediaone.net>

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@mediaone.net>
To: <pgsql-php@postgresql.org>
Cc: <pgsql-novice@postgresql.org>; <pgsql-general@postgresql.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




view thread (12+ messages)  latest in thread

Message-ID: <008b01c0d3d1$bfe11a00$330a0a0a@rutgersinsurance.com>
Permalink:  ../008b01c0d3d1$bfe11a00$330a0a0a@rutgersinsurance.com/
Also on:    postgresql.org/message-id/008b01c0d3d1$bfe11a00$330a0a0a@rutgersinsurance.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: aalang@rutgersinsurance.com
  Subject: Re: psql with PHP question
  In-Reply-To: <008b01c0d3d1$bfe11a00$330a0a0a@rutgersinsurance.com>
  References: <3AF1427C.B4E85A45@is3-design.com> <3AF149C1.AEC30AA9@mediaone.net> <008b01c0d3d1$bfe11a00$330a0a0a@rutgersinsurance.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox