Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f47CmRA63016 for ; Mon, 7 May 2001 08:48:27 -0400 (EDT) (envelope-from pgsql-general-owner@postgresql.org) Received: from cryanpc.us.greatbridge.com (cryanpc.us.greatbridge.com [65.196.69.72]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f43CrRA35214; Thu, 3 May 2001 08:53:27 -0400 (EDT) (envelope-from chris@greatbridge.com) Received: from greatbridge.com (IDENT:ryan@database [127.0.0.1]) by cryanpc.us.greatbridge.com (8.11.0/8.11.0) with ESMTP id f43CswY23998; Thu, 3 May 2001 08:54:58 -0400 Message-ID: <3AF15522.91A06E74@greatbridge.com> Date: Thu, 03 May 2001 08:54:58 -0400 From: Chris Ryan Organization: GreatBridge LLC X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.2.17-8smp i686) X-Accept-Language: en MIME-Version: 1.0 To: Jason CC: pgsql-php@postgresql.org, pgsql-novice@postgresql.org, pgsql-general@postgresql.org Subject: Re: [NOVICE] psql with PHP question References: <3AF1427C.B4E85A45@is3-design.com> <3AF149C1.AEC30AA9@mediaone.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200105/294 X-Sequence-Number: 9038 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