pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris Ryan <chris@greatbridge.com>
To: Jason <gee308@mediaone.net>
Cc: pgsql-php@postgresql.org
Cc: pgsql-novice@postgresql.org
Cc: pgsql-general@postgresql.org
Subject: Re: [NOVICE] psql with PHP question
Date: Thu, 03 May 2001 08:54:58 -0400
Message-ID: <3AF15522.91A06E74@greatbridge.com> (raw)
References: <3AF1427C.B4E85A45@is3-design.com>
	<3AF149C1.AEC30AA9@mediaone.net>

Jason,

	Look into the pg_result() function. You would use it something like
this:

$q = pg_Exec("SELECT id FROM article WHERE id=(SELECT MAX(id) FROM
article)");
$maxid = pg_result($q,0,0); # pg_result($result,$row,$column_num)
echo "The highest id is ". $maxid[0];

	Hope this helps.

Chris Ryan
chris@greatbridge.com

Jason wrote:
> 
> 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: <3AF15522.91A06E74@greatbridge.com>
Permalink:  ../3AF15522.91A06E74@greatbridge.com/
Also on:    postgresql.org/message-id/3AF15522.91A06E74@greatbridge.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: chris@greatbridge.com, gee308@mediaone.net, pgsql-novice@postgresql.org, pgsql-general@postgresql.org
  Subject: Re: [NOVICE] psql with PHP question
  In-Reply-To: <3AF15522.91A06E74@greatbridge.com>
  References: <3AF1427C.B4E85A45@is3-design.com> <3AF149C1.AEC30AA9@mediaone.net> <3AF15522.91A06E74@greatbridge.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