CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Tips & Solutions

 Multi Column, Multi Keyword Search for CCS ...

Print topic Send  topic

Author Message
feha


Posts: 712
Posted: 02/16/2008, 1:39 AM

  
	// add this code to Before BuildSelect event on your grid ...  
	// multi column and multi keyword seach for CodeCharge Studio  
	//Author: Femi Hasani www.vision.to  
	// for free use please keep credits above, thank you.  
  
	$keywords = array();  
  
	// columns must be CHAR, VCHAR or TEXT type ...  
	$search_columns = array("page_content","page_title");//add your columns as many as you want :  
  
	$keywords = CCGetFromGet(s_keyword,"");  
	$keywords = trim($keywords);	  
	$keywords = preg_split("/[\s,]+/", $keywords);  
	  
	$Component->ds->Where = "";  
  
	$l=0;  
	$Component->ds->Where .="(";  
	foreach ($keywords as $word)  
	{  
		if(strlen($word) > 2)  
		{  
		if ($l!=0) $Component->ds->Where .=") AND (";  
		$l=1;  
		$m=0;  
	foreach($search_columns as $column)  
	{  
		if ($m!=0) $Component->ds->Where .=" OR ";  
		$Component->ds->Where .=" $column LIKE '%$word%' ";  
		$m=1;  
	}//end foreach column  
  
	}  
	}//end foreach word  
	$Component->ds->Where .=")";  

enjoy
:-)
_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
wkempees
Posted: 02/16/2008, 4:18 AM

Thanks.
This could/should be easily converted to a CCS-IDE option....
to be a standard option within CCS, wish.

Walter

"feha" <feha@forum.codecharge> schreef in bericht
news:2547b6af3eec7d8@news.codecharge.com...
>
  
> // add this code to Before BuildSelect event on your grid ...  
> // multi column and multi keyword seach for CodeCharge Studio  
> //Author: Femi Hasani www.vision.to  
> // for free use please keep credits above, thank you.  
>  
> $keywords = array();  
>  
> // columns must be CHAR, VCHAR or TEXT type ...  
> $search_columns = array("page_content","page_title");//add your columns as  
> many as you want :  
>  
> $keywords = CCGetFromGet(s_keyword,"");  
> $keywords = trim($keywords);  
> $keywords = preg_split("/[\s,]+/", $keywords);  
>  
> $Component->ds->Where = "";  
>  
> $l=0;  
> $Component->ds->Where .="(";  
> foreach ($keywords as $word)  
> {  
> if(strlen($word) > 2)  
> {  
> if ($l!=0) $Component->ds->Where .=") AND (";  
> $l=1;  
> $m=0;  
> foreach($search_columns as $column)  
> {  
> if ($m!=0) $Component->ds->Where .=" OR ";  
> $Component->ds->Where .=" $column LIKE '%$word%' ";  
> $m=1;  
> }//end foreach column  
>  
> }  
> }//end foreach word  
> $Component->ds->Where .=")";  
> 
>
> enjoy
> :-)
> _________________
> Regards
> feha
> Vision.To Design
> www.vision.to
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>

feha


Posts: 712
Posted: 02/16/2008, 4:31 AM

Hi Walter

Thank you, yes i think this should be "standard" in CSS :-)

for those who know to build actions i think is not difficult to create an action BeforeBuild Select to add this code with an action ...

correction:
 CCGetFromGet(s_keyword,"")  should be CCGetFromGet("s_keyword","") .... 


_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
datadoit
Posted: 02/16/2008, 5:58 AM

if (feha != "the_man") {
feha = "the_man";
}
wkempees
Posted: 02/16/2008, 6:45 AM

;-)

"datadoit" <datadoit@forum.codecharge> schreef in bericht
news:fp6q5p$3it$1@news.codecharge.com...
> if (feha != "the_man") {
> feha = "the_man";
> }

DonP
Posted: 02/18/2008, 2:50 PM

I have been using virtually identical code for several years and have
always been surprised that CCS calls theirs "keyword" search when it is
actually "keyphrase" search. It makes it confusing for newcomers who
expect one thing and get another. The primary difference in mine is that
I filter out common words, such as "the", etc. with a simple
str_replace() and I have a highlighter to mark the words on the page in
red so that they stand out.

Don (DonP)

feha wrote:
>
  
> 	// add this code to Before BuildSelect event on your grid ...  
> 	// multi column and multi keyword seach for CodeCharge Studio  
> 	//Author: Femi Hasani www.vision.to  
> 	// for free use please keep credits above, thank you.  
>   
> 	$keywords = array();  
>   
> 	// columns must be CHAR, VCHAR or TEXT type ...  
> 	$search_columns = array("page_content","page_title");//add your columns as  
> many as you want :  
>   
> 	$keywords = CCGetFromGet(s_keyword,"");  
> 	$keywords = trim($keywords);	  
> 	$keywords = preg_split("/[\s,]+/", $keywords);  
> 	  
> 	$Component->ds->Where = "";  
>   
> 	$l=0;  
> 	$Component->ds->Where .="(";  
> 	foreach ($keywords as $word)  
> 	{  
> 		if(strlen($word) > 2)  
> 		{  
> 		if ($l!=0) $Component->ds->Where .=") AND (";  
> 		$l=1;  
> 		$m=0;  
> 	foreach($search_columns as $column)  
> 	{  
> 		if ($m!=0) $Component->ds->Where .=" OR ";  
> 		$Component->ds->Where .=" $column LIKE '%$word%' ";  
> 		$m=1;  
> 	}//end foreach column  
>   
> 	}  
> 	}//end foreach word  
> 	$Component->ds->Where .=")";  
> 
>
> enjoy
> :-)
> _________________
> Regards
> feha
> Vision.To Design
> www.vision.to
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>
Chris__T


Posts: 339
Posted: 05/06/2008, 1:19 PM

I'm trying to get this to work in ASP, but no such luck. Anyone try it in ASP yet? (and have it search only one column)

dim keywords(20)
dim Lnamestring


dim search_columns(1)
search_columns(0)="LName"

Lnamestring = CCGetFromGet("s_LName", Empty)

Lnamestring = trim(Lnamestring)

keywords = split(Lnamestring)

Employee2.datasource.Where = " "

dim p
p = 0

Employee2.DataSource.Where = Employee2.DataSource.Where & "("
dim word
dim m
dim column
for each word in keywords
if (len(word) > 2) then
if (p <> 0) then
Employee2.DataSource.Where = Employee2.DataSource.Where & ") AND ("
p=1
m=0
end if
for each column in search_columns
if (m <> 0) then
Employee2.DataSource.Where = Employee2.DataSource.Where & " OR "
Employee2.DataSource.Where = Employee2.DataSource.Where & " column LIKE '%word%' "
m=1
end if

next '//end foreach column
end if

next ' //end foreach word
Employee2.DataSource.Where = Employee2.DataSource.Where & ")"
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.