Framework  3.9
NumberSearchParameterHandler Class Reference

NumberSearchParameterHandler is a SearchParameterHandler for numeric database types. More...

+ Inheritance diagram for NumberSearchParameterHandler:
+ Collaboration diagram for NumberSearchParameterHandler:

Public Member Functions

 equal ($name, $value)
 Generates the constraint expression for equality matching parameters. More...
 
 any ($name, $value)
 Generate the constraint expression for matching any word in a group of words. More...
 
 like ($name, $value)
 Generates the constraint expression for 'like' matching parameters, i.e. More...
 
 startsWith ($name, $value)
 Generates the constraint expression for 'startsWith' matching parameters, i.e. More...
 
 from ($name, $from)
 Generates the constraint expression for 'from' matching parameters, i.e. More...
 
 to ($name, $to)
 Generates the constraint expression for 'to' matching parameters, i.e. More...
 
 range ($name, $from, $to)
 Generates the constraint expression for 'range' matching parameters, i.e. More...
 
 member ($name, $set)
 Generate the constraint expression for set membership matching paramters, matching values in a comma delimite set. More...
 
- Public Member Functions inherited from SearchParameterHandler
 all ($name, $value)
 Generate the constraint expression for matching all words in a group of words but allowing other words in between. More...
 
 fullName ($f_name, $l_name, $value)
 Generate the constraint expression for matching the f_name and l_name fields to a given value. More...
 
 checked ($name, $value)
 Generate the constraint expresssion for matching boolean only when the UI element is selected. More...
 

Detailed Description

NumberSearchParameterHandler is a SearchParameterHandler for numeric database types.

Author
andy

Definition at line 190 of file search_form.inc.

Member Function Documentation

◆ any()

NumberSearchParameterHandler::any (   $name,
  $value 
)

Generate the constraint expression for matching any word in a group of words.

Parameters
string$namethe name of the field
string$valuea string that may contain multiple words
Returns
string a SQL expression to peform the match

Reimplemented from SearchParameterHandler.

Definition at line 199 of file search_form.inc.

200  {
201  trace("NUMBER: ANY!!!", 3);
202 
203  if (strpos($value, ",") !== FALSE)
204  {
205  $value = explode(",", $value);
206  }
207 
208  checkNumeric($value);
209 
210  if (is_array($value))
211  {
212  if (count($value) == 0) return "";
213  return "$name in (".implode(",", array_values($value)).") ";
214  }
215  else return "$name=$value";
216  }
checkNumeric($p)
Security helper function.
Definition: functions.inc:630
trace($msg, $lvl=3, $callStack=null)
Send output to the trace log.
Definition: functions.inc:1010

◆ equal()

NumberSearchParameterHandler::equal (   $name,
  $value 
)

Generates the constraint expression for equality matching parameters.

Parameters
string$namethe name of the field
mixed$valuethe value to match
Returns
string a SQL expression to perform the match

Reimplemented from SearchParameterHandler.

Definition at line 192 of file search_form.inc.

193  {
194  checkNumeric($value);
195 
196  return "$name=$value";
197  }

◆ from()

NumberSearchParameterHandler::from (   $name,
  $from 
)

Generates the constraint expression for 'from' matching parameters, i.e.

matching values that are greater than or equal to the specified value.

Parameters
string$namethe name of the field
mixed$fromthe lower bound
Returns
string a SQL expression to perform the match

Reimplemented from SearchParameterHandler.

Definition at line 228 of file search_form.inc.

229  {
230  checkNumeric($from);
231  return "$name >= $from";
232  }

◆ like()

NumberSearchParameterHandler::like (   $name,
  $value 
)

Generates the constraint expression for 'like' matching parameters, i.e.

matching a substring or partial match.

Parameters
string$namethe name of the field
mixed$valuethe value to match
Returns
string a SQL expression to perform the match

Reimplemented from SearchParameterHandler.

Definition at line 218 of file search_form.inc.

219  {
220  die("Inappropriate matching mode");
221  }

◆ member()

NumberSearchParameterHandler::member (   $name,
  $set 
)

Generate the constraint expression for set membership matching paramters, matching values in a comma delimite set.

Parameters
string$namethe name of the field
string$seta comma delimited set of values to match
Returns
string a SQL expression to peform the match

Reimplemented from SearchParameterHandler.

Definition at line 256 of file search_form.inc.

257  {
258  trace("## NUMBERSEARCHPARAMETERHANDLER", 1);
259 
260  $values = $set;
261  if(is_array($set))
262  $values = implode(",", array_keys($set));
263  return "$name IN ($set)";
264  }

◆ range()

NumberSearchParameterHandler::range (   $name,
  $from,
  $to 
)

Generates the constraint expression for 'range' matching parameters, i.e.

matching values that within the range of the two specified values.

Parameters
string$namethe name of the field
string$fromthe lower bound
mixed$tothe value to match
Returns
string a SQL expression to perform the match

Reimplemented from SearchParameterHandler.

Definition at line 240 of file search_form.inc.

241  {
242  checkNumeric($from);
243  checkNumeric($to);
244 
245  return "($name >= $from AND $name <= $to)";
246  }

◆ startsWith()

NumberSearchParameterHandler::startsWith (   $name,
  $value 
)

Generates the constraint expression for 'startsWith' matching parameters, i.e.

matching a substring or partial match at the start of the field only.

Parameters
string$namethe name of the field
string$valuethe value to match
Returns
string a SQL expression to perform the match

Reimplemented from SearchParameterHandler.

Definition at line 223 of file search_form.inc.

224  {
225  die("Inappropriate matching mode");
226  }

◆ to()

NumberSearchParameterHandler::to (   $name,
  $to 
)

Generates the constraint expression for 'to' matching parameters, i.e.

matching values that are less than or equal to the specified value.

Parameters
string$namethe name of the field
mixed$tothe upper bound
Returns
string a SQL expression to perform the match

Reimplemented from SearchParameterHandler.

Definition at line 234 of file search_form.inc.

235  {
236  checkNumeric($to);
237  return "$name <= $to";
238  }

The documentation for this class was generated from the following file: