Re: [NOVICE] psql with PHP question

From: Chris Ryan <chris(at)greatbridge(dot)com>
To: Jason <gee308(at)mediaone(dot)net>
Cc: pgsql-php(at)postgresql(dot)org, pgsql-novice(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: [NOVICE] psql with PHP question
Date: 2001-05-03 12:54:58
Message-ID: 3AF15522.91A06E74@greatbridge.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice pgsql-php

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adam Lang 2001-05-03 13:05:38 Re: psql with PHP question
Previous Message Tod McQuillin 2001-05-03 12:49:14 Re: psql with PHP question

Browse pgsql-novice by date

  From Date Subject
Next Message Adam Lang 2001-05-03 13:05:38 Re: psql with PHP question
Previous Message Tod McQuillin 2001-05-03 12:49:14 Re: psql with PHP question

Browse pgsql-php by date

  From Date Subject
Next Message Adam Lang 2001-05-03 13:05:38 Re: psql with PHP question
Previous Message Tod McQuillin 2001-05-03 12:49:14 Re: psql with PHP question