[PHPLIB] $GLOBALS[$base] as a session variable in sqlquery.inc. From: Seiji Tokunaga (toku <email protected>)
Date: 04/05/00

Hi everyone!

the question:
Is it possible to make $GLOBALS[$base] in Sql_query persistent?

my situation:
I am making a page with Sql_Query & Table HTML Widgets Class.
I wanted the user to be able to query not only from the form
provided by sqlquery.inc but from the table (generated from the
Table Widget) also.

-- Sample HTML page ---
 +-------------------------------------------------------------------+
 |Search for: [field1 ] [contains] [ ] |
 | [More] [Fewer] [Reset Query] [Submit Query] |
 +-------------------------------------------------------------------+

field1 field2 field3 field4
a1 a2 a3 a4
b1 b2 b3 b4
-- Sample HTML page ---

For instance if I click "b1" then the page will be re-generated with
"field1 = b1" added to the query form.

I was able to do this by extending the "table" Class to allow querying from
each cell wrapped with <FORM> tags.
But to my limited understanding, the default usage of $GLOBALS[$base] are not
as persistent variables so for each cell, I had to use <INPUT> tag for
each $GLOBALS[$base] like this:

function formcell($sel,$comp,$input,$conj) {
  global $q,$x,$sess; // $x is $GLOBALS[$base]
  $nc = $q->conditions;
  $i = "input_" . $nc;
  if(!empty($x[$i])) $nc++;
  for($i=1;$i<$nc;$i++){
    $xs .= "<input type=\"hidden\" name=\"x[sel_$i]\" value=\"".$x["sel_".$i]."\
">";
    $xs .= "<input type=\"hidden\" name=\"x[comp_$i]\" value=\"".$x["comp_".$i].
"\">";
    $xs .= "<input type=\"hidden\" name=\"x[input_$i]\" value=\"".$x["input_".$i
]."\">";
    $xs .= "<input type=\"hidden\" name=\"x[conj_$i]\" value=\"".$x["conj_".$i].
"\">";
  }
  print("<form method=\"post\" action=\"".$sess->self_url()."\">" .
        "<input type=\"hidden\" name=\"x[sel_$nc]\" value=\"$sel\">" .
        "<input type=\"hidden\" name=\"x[comp_$nc]\" value=\"$comp\">" .
        "<input type=\"hidden\" name=\"x[input_$nc]\" value=\"$input\">" .
        "<input type=\"hidden\" name=\"x[conj_$nc]\" value=\"$conj\">" .
        "<input type=\"hidden\" name=\"conditions\" value=\"$nc\">" .
        "<input type=\"submit\" value=\"$input\">" .
        $xs . "</form>");
}

But I feel it's much easier and efficient if $GLOBALS[$base]
were made persistent.

After minor modifications, I tried "$sess->register("x")". But it fails
after the 1st query (the 1st query works!)...
It seems to me that a new array element (ex. x[sel_2]) fails to be persistent...

If anybody knows what's going on, I'd appreciate some input. Thanks.
===================--------------------===================
Seiji Tokunaga (toku <email protected>)
NEC Informatec Systems, Network SI Div., 1st SI Dept.
  TEL: 044-856-8481 FAX: 044-856-2273
  NEC TEL: 272-5610 FAX: 272-5649 MAIL:272-5600
-------------------====================-------------------
-
PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
the body, not the subject, of your message.