Re: problem with SUM and Postgres
| From: | Marco Tabini | Date: | Wed, 09 Oct 2002 23:32:38 +0000 |
| Subject: | Re: problem with SUM and Postgres | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-119477@lists.php.net to get a copy of this message | ||
Because pg_exec only executes the query and returns the resource that's
associated with the returns. If you want to read the results, you should
use pg_fetch_result():
$sql1 = "SELECT SUM(hostingcost) FROM $tablename WHERE webserver =
'$webserver'";
$hosting_rs = pg_exec($connect, $sql1);
$hosting_data = pg_fetch_row ($hosting_rs, 0);
$hosting = $hosting_data[0];
Marco
On Wed, 2002-10-09 at 19:29, webmaster wrote:
> I can't figure out why the following code is not returning a column
> total:
>
> $sql1 = "SELECT SUM(hostingcost) FROM $tablename WHERE webserver =
> '$webserver'";
> $hosting = pg_exec($connect, $sql1);
> echo $hosting;
>
> This returns: Resource ID #3
>
> The only thing I can think of is that the hostingcost column's default
> value is set to MONEY which is a postgres specific constraint. The
> query works fine within psql on the server, but not with php.
>
> Thanks for any help.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>