Solved: Is this possible or am I on drugs :) - Mailing list pgsql-general

From shawn everett
Subject Solved: Is this possible or am I on drugs :)
Date
Msg-id Pine.LNX.4.30.0011281457390.16991-100000@alder.pgweb.com
Whole thread Raw
In response to Re: Is this possible or am I on drugs :)  (Ron Chmara <ron@opus1.com>)
List pgsql-general
Thanks for everyone's responses :)

It seems I simply wasn't able to explain what I was trying to do.  I knew
how to do this with PHP already.

On the bright side I've decided to do things the way you think I'm doing
them, rather than the way I was thinking of doing them :)  How's that for
cryptic? :)

I'll end this thread now and not confuse the list with my rambling
thoughts for the imediate future. :)

Thanks once again for all the reponses.

Shawn

On Tue, 28 Nov 2000, Ron Chmara wrote:

> shawn everett wrote:
> > > What do you consider "passing a parameter to the view" to be?
> > This is where Microsoft Access has twisted me :)
> > Access as you may or may not know allows you to use parameters in a query:
> > SELECT * FROM table WHERE table.pkey=[Enter The Primary Key];
> > The bit in [] represents a prompt to the user.  They can also be filled in
> > programatically.
>
> In PHP, that's just a variable passed from a prior page....
>
> > The basic select statement for my problem is going to work as follows:
> > select colA, colB, colA+colB*0.4 as f1, colC, colC+colD*9 as f2 from table
> > where date=SomeDateEnteredByTheUser;
> > Can I pass SomeDateEnteredByTheUser to Postgres in some way and get back
> > the set of records I want?  If I can is there a way to call this from PHP?
>
> You _are_ asking pretty much a basic PHP question.
>
> $result = pg_exec($conn,"select colA, colB, colA+colB*0.4 as f1, colC, colC+colD*9
> as f2 from table where date=$SomeDateEnteredByTheUser;");
>
> Where you are passing "$SomeDateEnteredByTheUser" from a prior page as
> a form item.
>
> Want to get really wacky? Make them all variables, passed from the prior
> page....($colA, $colB, $colC, $colD, $f1, $f2, $table, etc..)
>
>
> $built_statement =  "select $colA, $colB, $colA"."+".$colB"."*"."0.4 "
> $built_statement =. "as $f1, $colC, $colC"."+"."$colD"."*"."9 as $f2"
> $built_statement =. " from $table where date= $SomeDateEnteredByTheUser";
>
> $result = pg_exec($conn, $built_statement);
>
> > If I can't and end up dynamically writing the query and sumbitting that
> > to Postgres is this a smart way to do it?
> > Or should I simply query out the basic values: colA, colB, colC and colD
> > and then do the calculations within PHP?
>
> Either way works. <shrug>. I do lot's of my calcs in PHP, because I can
> quickly edit them at the same time as my display code. Other things are
> far too complex or repetitive to bother PHP with, so I do 'em in Pg. In
> general, though, you'll find your code more flexible if it's variable
> driven....
>
> -Bop
>
> --
> Brought to you from boop!, the dual boot Linux/Win95 Compaq Presario 1625
> laptop, currently running RedHat 6.1. Your bopping may vary.
>


pgsql-general by date:

Previous
From: Ashley Clark
Date:
Subject: Re: How to view the code in a function??
Next
From: "Valter Mazzola"
Date:
Subject: JReplico: GPLed java distributed database replication system.