Received: from bush.rutgersinsurance.com (rutgersinsurance.com [38.138.71.194]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f43D45A38343 for ; Thu, 3 May 2001 09:04:05 -0400 (EDT) (envelope-from aalang@rutgersinsurance.com) Received: from 6014cwpza006 (adam.rutgersinsurance.com [10.10.10.51]) by bush.rutgersinsurance.com (8.9.3/8.9.3) with SMTP id JAA24407 for ; Thu, 3 May 2001 09:15:41 -0400 Message-ID: <008b01c0d3d1$bfe11a00$330a0a0a@rutgersinsurance.com> From: "Adam Lang" To: References: <3AF1427C.B4E85A45@is3-design.com> <3AF149C1.AEC30AA9@mediaone.net> Subject: Re: psql with PHP question Date: Thu, 3 May 2001 09:05:38 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200105/11 X-Sequence-Number: 320 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" To: Cc: ; 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