Skip site navigation (1) Skip section navigation (2)

Re: psql with PHP question

From: Philip Hallstrom <philip(at)adhesivemedia(dot)com>
To: Chris Ryan <chris(at)greatbridge(dot)com>
Cc: Jason <gee308(at)mediaone(dot)net>, <pgsql-php(at)postgresql(dot)org>, <pgsql-novice(at)postgresql(dot)org>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: psql with PHP question
Date: 2001-05-03 15:29:49
Message-ID: Pine.BSF.4.31.0105030828560.38876-100000@oddjob.adhesivemedia.com (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-novicepgsql-php
Also... is there any reason you don't just do:

SELECT MAX(id) FROM article

rather than what you have below?  It would get you the same thing wouldn't
it and save a query...

On Thu, 3 May 2001, Chris Ryan wrote:

> 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(at)greatbridge(dot)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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>


In response to

Responses

pgsql-novice by date

Next:From: Gyozo PappDate: 2001-05-03 16:19:10
Subject: Re: [PHP] psql with PHP question
Previous:From: Adam LangDate: 2001-05-03 14:28:40
Subject: Re: 2 more questions(Was: Re: psql with PHP question)

pgsql-php by date

Next:From: Gyozo PappDate: 2001-05-03 16:19:10
Subject: Re: [PHP] psql with PHP question
Previous:From: Adam LangDate: 2001-05-03 14:28:40
Subject: Re: 2 more questions(Was: Re: psql with PHP question)

pgsql-general by date

Next:From: armelle clechDate: 2001-05-03 15:33:08
Subject: Visual StudioC++ 6.0 project configuration for postgresql use
Previous:From: Joel BurtonDate: 2001-05-03 15:26:12
Subject: Re: Adress Database

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group