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

Re: [PHP] psql with PHP question

From: "Gyozo Papp" <pgerzson(at)freestart(dot)hu>
To: "Jason" <gee308(at)mediaone(dot)net>, <pgsql-php(at)postgresql(dot)org>
Cc: <pgsql-novice(at)postgresql(dot)org>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: [PHP] psql with PHP question
Date: 2001-05-03 16:19:10
Message-ID: 011301c0d3ec$cd91c940$5145c5d5@jaguar (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-novicepgsql-php
In my opinion, these queries make the same :
SELECT id FROM article WHERE id=(SELECT MAX(id) FROM article);
SELECT MAX(id) FROM article;

but the latter one is much more simple and you do not overload your pg.
(by the way, I think id = (SELECT ...) isn't handled gracefully.)

----- 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: 2001. május 3. 14:06
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

pgsql-novice by date

Next:From: Stephen M. FordDate: 2001-05-03 16:29:07
Subject: input from a file
Previous:From: Philip HallstromDate: 2001-05-03 15:29:49
Subject: Re: psql with PHP question

pgsql-php by date

Next:From: Andrew McMillanDate: 2001-05-04 08:07:44
Subject: Re: [NOVICE] Re: psql with PHP question
Previous:From: Philip HallstromDate: 2001-05-03 15:29:49
Subject: Re: psql with PHP question

pgsql-general by date

Next:From: Roger WernerssonDate: 2001-05-03 16:29:23
Subject: optimizing
Previous:From: will trillichDate: 2001-05-03 16:12:22
Subject: Re: Perl Scope problem

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