Thread: pg_query & $result re-fill

pg_query & $result re-fill

From
Stefan Schwarzer
Date:
Hi there,

I used to pass a the $result of a pg_query to a function which detects
min, max etc.

Now, I inserted before that another query which first queries a set of
parameters for the selected regions. Only if these parameters are
fulfilled for each of the regions, the values of the above query shall
be analyzed. Otherwise, they should be set to "NULL".

Now, as I am sending the ($result) to the function, I wonder if I can
change the values within the $result; or create a new $result based on
a couple of PHP-IFs?

Here is how it looks like:



Here is a query to retrieve the values for the selected regions and a
couple of years:

    $result = pg_query("....");

The "result" looks like this:

    |     1999 |   2000 |  2001 ....
A     |       23    |    24     |    23
B     |      12     |   15      |  18
C ....


Here is a query which load a couple of parameters:

    $result_params = pg_query("....");


Here I would like to check:

    IF param1 < 75 THEN region-in-$result-should-be-set-to-NULL


This is the call to the function:

    $values = $h -> getValues($result, $selectedYear);



So, the question is again: Can I change values within the $result? I
have no idea how the array (?) actually looks like...

Thanks for any suggestion,

Stef

Re: pg_query & $result re-fill

From
"Scott Marlowe"
Date:
On Tue, Jun 10, 2008 at 9:33 AM, Stefan Schwarzer
<stefan.schwarzer@grid.unep.ch> wrote:

> Here I would like to check:
>
>        IF param1 < 75 THEN region-in-$result-should-be-set-to-NULL

Not sure I get what all you're wanting to do from your message, but
could you use a case statement in sql to do this?  Or put it in the
where clause?

Re: pg_query & $result re-fill

From
Stefan Schwarzer
Date:
>> Here I would like to check:
>>
>>       IF param1 < 75 THEN region-in-$result-should-be-set-to-NULL
>
> Not sure I get what all you're wanting to do from your message, but
> could you use a case statement in sql to do this?  Or put it in the
> where clause?

I knew it too be a bit complicated to explain....

Basically, it's more a PHP question, I guess. And that is if there is
a way to "infiltrate" the $result and change values within. Something
like

            $result[2][6] = "other value";