Packageindex Classtrees Modulegroups Elementlist Report XML Files

Softerra

SQL::SQLSearch

public module SQLSearch

SQL Keywords Search Library.

Linkshttp://www.softerra.com/products/ - [Softerra PHP Developer Library Home Page]
AuthorsSofterra <phplib@softerra.com>
SincePHP 4.0.1pl2
Version1.3.6
Copyright(c) 1999-2002 Softerra, LLC

 

Public Method Summary

string targetfield([ string $target ])
Setting field name for keyword search.
string expression2conditions(string $expression, [ integer $type ])
Returns the composed WHERE part of SQL query.
string standalone(string $conditions)
Returns the prepared WHERE part of SQL query.

Private Method Summary

string searchPattern(string $pattern, [ integer $type ])
Prepares and returns the search keyword.
void re_k2c(string &$keyword, integer $number, array $extension)
Prepares search keywords.
void sql_k2c(string &$keyword, integer $number, array $extension)
Prepares search keywords.
array keywords2conditions(array $keywords, [ integer $type, array $extension ])
Returns prepared search keywords array.
array expression2internal(string $expression)
Returns prepared search array.
string composeSearchConditions(array $keywords, integer $type, [ string $operation, boolean $negation ])
Returns part of the WHERE condition.

Private Constant Summary

SQL_PATTERN >>0<< SQL type of search pattern.
REGEXP_PATTERN >>1<< REGEXP type of search pattern.
KWFIELD >>KEYWORDS<< Name of field for search.
SEARCHEXP_SEPARATOR >> <<
SYMBOL_ANYCHAR >>?<< "Any symbol" search pattern.
SYMBOL_ANYSEQUENCE >>*<< "Any symbol sequence" search pattern.
SQL_ANYCHAR >>_<< "Any symbol" SQL search pattern.
SQL_ANYSEQUENCE >>%<< "Any symbol sequence" SQL search pattern.
REGEXP_ANYCHAR >>[[:alnum:] ]<< "Any symbol" REGEXP search pattern.
REGEXP_SEPARATOR >>,<< REGEXP search pattern "separator".
REGEXP_ANYSEQUENCE >>[[:alnum:]]*<< "Any symbol sequence" REGEXP search pattern.

Public Method Details

targetfield

public string targetfield( [ string $target ] )

  Setting field name for keyword search.

Parameter
string $target = >>""<<
Field name for keyword search.
Returns string

Field name for keyword search.

Required global variables
string $targetField

expression2conditions

public string expression2conditions( string $expression, [ integer $type ] )

  Returns the composed WHERE part of SQL query.

Converts the word1 word2 +word3 -word4 "word5 word6" types of SQL search to the WHERE part of SQL query.

Parameter
string $expression
Search string.
integer $type = >>0<<
Type of search pattern.
Returns string

WHERE part of SQL query.


standalone

public string standalone( string $conditions )

  Returns the prepared WHERE part of SQL query.

Returns the prepared WHERE part of SQL query with the "WHERE" string. Should be used with expression2conditions().

Parameter
string $conditions
SQL query conditions.
Returns string

Prepared WHERE part of SQL query.

See Also expression2conditions()

Private Method Details

searchPattern

private string searchPattern( string $pattern, [ integer $type ] )

  Prepares and returns the search keyword.

Prepares and returns the search keyword to be used in SQL or REGEXP search patterns.

Parameter
string $pattern
Search keyword.
integer $type = >>0<<
Type of search pattern.
Returns string

Prepared search keyword.


re_k2c

private void re_k2c( string &$keyword, integer $number, array $extension )

  Prepares search keywords.

Prepares search keywords to be used in REGEXP search patterns.

Parameter
string &$keyword
Search keyword.
integer $number
Keywords array key.
array $extension
Additional condition prefix and suffix.
Returns void


sql_k2c

private void sql_k2c( string &$keyword, integer $number, array $extension )

  Prepares search keywords.

Prepares search keywords to be used in SQL search patterns.

Parameter
string &$keyword
Search keyword.
integer $number
Keywords array key.
array $extension
Additional condition prefix and suffix.
Returns void

Required global variables
boolean $sqlExtendedSearch Defines search mode.

keywords2conditions

private array keywords2conditions( array $keywords, [ integer $type, array $extension ] )

  Returns prepared search keywords array.

Returns search keywords array prepared for use in SQL query.

Parameter
array $keywords
Searh keywords.
integer $type = >>0<<
Type of search pattern.
array $extension = >>array()<<
Additional condition prefix and suffix.
Returns array

Search keywords array.


expression2internal

private array expression2internal( string $expression )

  Returns prepared search array.

Returns prepared search array for the expression2conditions() function.

Parameter
string $expression
Search string.
Returns array

Prepared search array.

See Also expression2conditions()

composeSearchConditions

private string composeSearchConditions( array $keywords, integer $type, [ string $operation, boolean $negation ] )

  Returns part of the WHERE condition.

Returns part of the WHERE condition.

Parameter
array $keywords
Search keywords.
integer $type
Type of search pattern.
string $operation = >>"or"<<
Logical operation OR or AND.
boolean $negation = >>false<<
If TRUE set WHERE prefix to NOT.
Returns string

Part of the WHERE condition.


Private Constant Details

SQL_PATTERN

define( SQL_PATTERN, >>0<< )
Case: default: case sensitive

SQL type of search pattern.


REGEXP_PATTERN

define( REGEXP_PATTERN, >>1<< )
Case: default: case sensitive

REGEXP type of search pattern.


KWFIELD

define( KWFIELD, >>KEYWORDS<< )
Case: default: case sensitive

Name of field for search.


SEARCHEXP_SEPARATOR

define( SEARCHEXP_SEPARATOR, >> << )
Case: default: case sensitive


SYMBOL_ANYCHAR

define( SYMBOL_ANYCHAR, >>?<< )
Case: default: case sensitive

"Any symbol" search pattern.


SYMBOL_ANYSEQUENCE

define( SYMBOL_ANYSEQUENCE, >>*<< )
Case: default: case sensitive

"Any symbol sequence" search pattern.


SQL_ANYCHAR

define( SQL_ANYCHAR, >>_<< )
Case: default: case sensitive

"Any symbol" SQL search pattern.


SQL_ANYSEQUENCE

define( SQL_ANYSEQUENCE, >>%<< )
Case: default: case sensitive

"Any symbol sequence" SQL search pattern.


REGEXP_ANYCHAR

define( REGEXP_ANYCHAR, >>[[:alnum:] ]<< )
Case: default: case sensitive

"Any symbol" REGEXP search pattern.


REGEXP_SEPARATOR

define( REGEXP_SEPARATOR, >>,<< )
Case: default: case sensitive

REGEXP search pattern "separator".


REGEXP_ANYSEQUENCE

define( REGEXP_ANYSEQUENCE, >>[[:alnum:]]*<< )
Case: default: case sensitive

"Any symbol sequence" REGEXP search pattern.



Packageindex Classtrees Modulegroups Elementlist Report XML Files