Tobias Weik
|
| Posted: 02/05/2003, 6:28 AM |
|
hi to all "heavy coders" ;)
It might be a simple question but can't figure out the right way:
I have a searchform with a textfield {s_keyword} and a checkbox
{is_soundex} - my searchresult is a grid on the same page (so nothing
special for now).
I want to define 2 different queries, depending on the un-/selected
checkbox: if the checkbox is unselected, my source for the grid simply
is "SELECT * FROM sometable WHERE searchstring LIKE '%{s_keyword}%'".
But if the checkbox is selected, my query should use the MySQL soundex()
function for a more lax (phonetic) search...
My main problem is: How (and where?) do I define different queries,
dependig on a "flag" like this checkbox?
I am using CCS 1.07 with PHP and MySQL - tia
Tobias
|
|
|
 |
Kasper Pedersen
|
| Posted: 02/07/2003, 5:49 AM |
|
This should do the trick !
Best regards
Kasper
'------------------------------------------------------
ASP at: "BuildTableWhere Method"
AFTER: .Criterion(1) = .Operation(opContains ....
'------------------------------------------------------
response.write "BEFORE [" & .Criterion(1) & "]"
if SOMEVALUE = 1 then
.Criterion(1) = "SOUNDEX(" &
replace(
replace(.Criterion(1),"%",""),
" like ",
") = SOUNDEX("
)
& ")"
response.write "AFTER [" & .Criterion(1) & "]"
'-----------------------------------------------------
"Tobias Weik" <tw@ccug.de> wrote in message
news:b1r722$q1m$1@news.codecharge.com...
> hi to all "heavy coders" ;)
>
> It might be a simple question but can't figure out the right way:
>
> I have a searchform with a textfield {s_keyword} and a checkbox
> {is_soundex} - my searchresult is a grid on the same page (so nothing
> special for now).
>
> I want to define 2 different queries, depending on the un-/selected
> checkbox: if the checkbox is unselected, my source for the grid simply
> is "SELECT * FROM sometable WHERE searchstring LIKE '%{s_keyword}%'".
> But if the checkbox is selected, my query should use the MySQL soundex()
> function for a more lax (phonetic) search...
>
> My main problem is: How (and where?) do I define different queries,
> dependig on a "flag" like this checkbox?
>
> I am using CCS 1.07 with PHP and MySQL - tia
>
> Tobias
>
|
|
|
 |
Kasper Pedersen
|
| Posted: 02/07/2003, 6:15 AM |
|
/&&/(&(/ ... her is the PHP code
Best regards
Kasper
--------------
function Prepare()
{
.....
$this->wp->Criterion[1] = ...
--------------
// INSERTED CODE
echo "BEFORE [" . $this->wp->Criterion[1] . "]<BR>"; //DEBUG
$temp = $this->wp->Criterion[1];
$temp = eregi_replace("\%", "", $temp);
$temp = "SOUNDEX(" . eregi_replace(" like ", ") = SOUNDEX(", $temp) . ")";
$this->wp->Criterion[1] = $temp;
echo "AFTER [" . $this->wp->Criterion[1] . "]<BR>"; //DEBUG
// INSERTED CODE END
------------
$this->Where = $this->wp->Criterion[1];
....
}
------------
"Tobias Weik" <tw@ccug.de> wrote in message
news:b1r722$q1m$1@news.codecharge.com...
> hi to all "heavy coders" ;)
>
> It might be a simple question but can't figure out the right way:
>
> I have a searchform with a textfield {s_keyword} and a checkbox
> {is_soundex} - my searchresult is a grid on the same page (so nothing
> special for now).
>
> I want to define 2 different queries, depending on the un-/selected
> checkbox: if the checkbox is unselected, my source for the grid simply
> is "SELECT * FROM sometable WHERE searchstring LIKE '%{s_keyword}%'".
> But if the checkbox is selected, my query should use the MySQL soundex()
> function for a more lax (phonetic) search...
>
> My main problem is: How (and where?) do I define different queries,
> dependig on a "flag" like this checkbox?
>
> I am using CCS 1.07 with PHP and MySQL - tia
>
> Tobias
>
|
|
|
 |
Tobias Weik
|
| Posted: 02/07/2003, 6:43 AM |
|
hi kasper,
greetings to denmark from hamburg and many thanks for your help - I will
give it a try this weekend and let you know if it worked!
thanks again,
tobias
Kasper Pedersen schrieb:
> /&&/(&(/ ... her is the PHP code
>
> Best regards
> Kasper
>
> --------------
> function Prepare()
> {
> .....
> $this->wp->Criterion[1] = ...
> --------------
> // INSERTED CODE
>
> echo "BEFORE [" . $this->wp->Criterion[1] . "]<BR>"; //DEBUG
>
> $temp = $this->wp->Criterion[1];
> $temp = eregi_replace("\%", "", $temp);
> $temp = "SOUNDEX(" . eregi_replace(" like ", ") = SOUNDEX(", $temp) . ")";
> $this->wp->Criterion[1] = $temp;
>
> echo "AFTER [" . $this->wp->Criterion[1] . "]<BR>"; //DEBUG
>
> // INSERTED CODE END
>
> ------------
> $this->Where = $this->wp->Criterion[1];
> ....
> }
> ------------
|
|
|
 |
|