
Static Public Member Functions | |
| static | execute ($req, $mode=self::MODE_METADATA) |
| Executes a search request. | |
| static | grep ($pattern, $domain= '//', $types=array(), $options=array(), $statuses=array()) |
| Searches for content using regular expressions. | |
Static Private Member Functions | |
| static | buildConstraints ($type, $constraints, $conj) |
| Generates WHERE clause for search. | |
| static | buildSelect ($type, $domain, $mode) |
| Builds the SELECT ... part of the search query. | |
| static | convertOp ($v, $op) |
| Converts operators and values to proper SQL. | |
To use this class, create a SnapSearchRequest object, fill it with the search parameters and then call SnapSearch::execute() with the object to get the results. This class also supports grepping of content with regular expressions (SnapSearch::grep()).
Definition at line 12 of file SnapSearch.php5.
| static SnapSearch::buildConstraints | ( | $ | type, | |
| $ | constraints, | |||
| $ | conj | |||
| ) | [static, private] |
Generates WHERE clause for search.
For internal use only.
The WHERE clause is based on the constraints given and the types searched over
| $type | [string]: which type is being searched over | |
| $constraints | [array]: array of arrays, the inner arrays containing three elements:
| |
| $conj | [string]: one of SnapSearchRequest::CONJ_* constants |
Definition at line 550 of file SnapSearch.php5.
| static SnapSearch::buildSelect | ( | $ | type, | |
| $ | domain, | |||
| $ | mode | |||
| ) | [static, private] |
Builds the SELECT ... part of the search query.
For internal use only.
This does not include the FROM clause or any joins, just essentially the list of variables that need to be selected.
| $type | [int]: filesystem object type | |
| $domain | [string]: path prefix that describes where in the filesystem tree to filter the search results | |
| $mode | [int]: one of the MODE_* constants as given above (only MODE_LIST is checked) |
Definition at line 377 of file SnapSearch.php5.
| static SnapSearch::convertOp | ( | $ | v, | |
| $ | op | |||
| ) | [static, private] |
Converts operators and values to proper SQL.
For internal use only.
This method exists to translate SnapSearchRequest::OP_* constants to the appropriate SQL equivalent.
| $v | [mixed]: target value of operator | |
| $op | [int]: operator |
Definition at line 613 of file SnapSearch.php5.
| static SnapSearch::execute | ( | $ | req, | |
| $ | mode = self::MODE_METADATA | |||
| ) | [static] |
Executes a search request.
Build a SnapSearchRequest object first, and pass it to this method to get the results. You can get the results in several formats based on what you pass in the 2nd argument:
MODE_LIST: array of paths for each matching filesystem object, along with some additional informationMODE_METADATA: like MODE_LIST, but include the complete file metadata in the result arrayMODE_ALL: same as MODE_METADATA, but include version content (which would otherwise be excluded)MODE_OBJECTS: return Snap2 objectsMODE_ALL_OBJECTS: combines MODE_OBJECTS and MODE_ALL| $req | [SnapSearchRequest]: request object that defines the search criteria | |
| $mode | [int]: one of the MODE_* constants as described above |
Definition at line 40 of file SnapSearch.php5.
References SnapVersion::$ATTRIBUTES, SnapResource::$ATTRIBUTES, STimer::end(), STimer::endAvg(), SObject::getLastStaticError(), SnapDBI::query(), STimer::start(), and STimer::startAvg().
| static SnapSearch::grep | ( | $ | pattern, | |
| $ | domain = '//', |
|||
| $ | types = array(), |
|||
| $ | options = array(), |
|||
| $ | statuses = array() | |||
| ) | [static] |
Searches for content using regular expressions.
This method takes a pattern and some options and finds versions that have content that matches the regular expression pattern provided. The $options parameter is an array that may contain zero or more of the following constants:
GREP_CASE_INSENSITIVE: do a case-insensitive match (like the '/i' flag on regexes)GREP_MULTILINE: makes '^' and '$' match beginning and end of line instead of beginning and end of stringGREP_MATCH_NEWLINE: makes '.' match newline characters (default is not to)GREP_MATCH_ALL: include all matches from a version, not just that the version matchedIf GREP_MATCH_ALL is used, the method returns an array indexed by path for each matching version. The value of each array is a sub-array that contains a list of two-element arrays, where the first element is the entire line (or set of lines) containing the match and the second element is just the portion of the line that matched.
| $pattern | [string]: regular expression pattern to match | |
| $domain | [string]: path to directory or resource under which to search versions for pattern | |
| $types | [array]: list of content types that should be searched (see SnapResource) | |
| $options | [array]: one of the GREP_* constants as described above | |
| $statuses | [array]: list of version statuses that should be searched (see SnapVersion) |
Definition at line 299 of file SnapSearch.php5.
References STimer::endAvg(), and STimer::startAvg().
1.5.6