SQL Yoga version 1.1.0 build 4 :: Visit website

Printer friendly version

command sqlquery_setConditionsFromUserSearchString

Converts a search string into the condition property of a SQL Query Object.

command sqlquery_setConditionsFromUserSearchString @pQueryA, pString, pConditions, pDefaultOperator
Parameters
TypeNameDescription
Simple parameter. @pQueryA A SQL Query Object array.
Simple parameter. pString A string representing the terms a user wants to search for.
Simple parameter. pConditions A string representing the SQL WHERE clause. :1 appears where you want to insert search terms. You do no need to wrap :1 in single quotes as this function always assumes you are searching for a string and wraps the strings in single quotes for you.
Simple parameter. pDefaultOperator Default boolean operator to use between words that do not explicity state one. Valid values are "AND" or "OR". Default value is "AND".
Description

Search interfaces often allow a user to enter a search string for querying the database.
A string entered by the user as

tacos pizza

might look like this in a WHERE clause:
field = 'tacos' AND field='pizza'

or
field='tacos' OR field='pizza'

A search string such as
"cheese pizza" tacos

might look like this in a WHERE clause:
field = 'cheese pizza' OR field='tacos'


This command takes a search string and combines it with the conditions of a WHERE clause and applies them to a SQL Query Object.

For example, if you passed in the string
"cheese pizza" taco

with a default operator of "OR" and the conditions were "food.name contains :1" then the following WHERE clause would be generated for the query:

WHERE (food.name LIKE  '%cheese pizza%' OR food.name LIKE '%tacos%')


You can see that the WHERE clause searches the name field of the food table for both terms.

Return

Error message.

See also