DBSqlBuilderWhereSphinx Class Reference
[Sphinx]
Where Clause Query Builder for Sphinx. More...
Inheritance diagram for
DBSqlBuilderWhereSphinx:
Public Member Functions |
|
get_sql () | |
Return SQL fragment. |
|
Protected Member Functions |
|
prefix_column ($column, $table) | |
Prefix column with table alias. |
|
process_as_filter ($columm, $operator, $value) | |
Create a filter from WHERE. |
|
process_as_query ($column, $operator, $value, $table) | |
Create a query from WHERE. |
Detailed Description
Where Clause Query Builder for Sphinx.
Definition at line 8 of file dbsqlbuilder.where.sphinx.cls.php.
Member Function Documentation
DBSqlBuilderWhereSphinx::get_sql | ( | ) |
Return SQL fragment.
- Returns:
- array Array with two members "filter" and "query"
Reimplemented from DBSqlBuilderWhere.
Definition at line 14 of file dbsqlbuilder.where.sphinx.cls.php.
00014 { 00015 $operator = $this->where->get_operator(); 00016 $column = $this->where->get_column(); 00017 /* @var $table DBTable */ 00018 $value = $this->where->get_value(); 00019 $table = $this->where->get_table(); 00020 $dbfield = $table->get_table_field($column); 00021 00022 $ret = array('filter' => array(), 'query' => ''); 00023 if ($dbfield && $dbfield->has_policy(DBDriverSphinx::SPHINX_ATTRIBUTE)) { 00024 // Attributes must be filtered 00025 $ret['filter'][] = $this->process_as_filter($column, $operator, $value, $table); 00026 } 00027 else { 00028 $ret['query'] = $this->process_as_query($column, $operator, $value, $table); 00029 } 00030 return $ret; 00031 }
DBSqlBuilderWhereSphinx::prefix_column | ( | $ | column, | |
$ | table | |||
) | [protected] |
Prefix column with table alias.
- Parameters:
-
string $column IDBTable | string $table
- Returns:
- string
Reimplemented from DBSqlBuilderWhere.
Definition at line 110 of file dbsqlbuilder.where.sphinx.cls.php.
00110 { 00111 return '@' . DB::escape_database_entity($column, $table->get_table_driver(), IDBDriver::FIELD); 00112 }
DBSqlBuilderWhereSphinx::process_as_filter | ( | $ | columm, | |
$ | operator, | |||
$ | value | |||
) | [protected] |
Create a filter from WHERE.
- Parameters:
-
string $column string $operator mixed $value IDTable $table
Definition at line 79 of file dbsqlbuilder.where.sphinx.cls.php.
00079 { 00080 $exclude = false; 00081 $values = Arr::force($value, true); 00082 switch ($operator) { 00083 case '=': 00084 case DBWhere::OP_IN: 00085 $exclude = false; 00086 break; 00087 case '!=': 00088 case '<>': 00089 case DBWhere::OP_NOT_IN: 00090 $exclude = true; 00091 break; 00092 default: 00093 throw new Exception('Only =, != and IN, NOT IN operator supported with sphinx attributes at this time'); 00094 break; 00095 } 00096 return array( 00097 'attribute' => $columm, 00098 'exclude' => $exclude, 00099 'values' => $values 00100 ); 00101 }
DBSqlBuilderWhereSphinx::process_as_query | ( | $ | column, | |
$ | operator, | |||
$ | value, | |||
$ | table | |||
) | [protected] |
Create a query from WHERE.
- Parameters:
-
string $column string $operator mixed $value IDTable $table
Definition at line 41 of file dbsqlbuilder.where.sphinx.cls.php.
00041 { 00042 if (empty($operator)) { 00043 return $column; 00044 } 00045 00046 /* @var $table DBTable */ 00047 $field = $this->prefix_column($column, $table); 00048 switch ($operator) { 00049 case '=': 00050 $value = DB::escape($value, $table->get_table_driver()); 00051 break; 00052 default: 00053 throw new Exception('Only = operator supported with sphinx queries at this time'); 00054 break; 00055 } 00056 $ret = $field . ' ' . $value; 00057 // There is a bug in Sphinx 0.9.9 that if query ends on some escaped characters, query fails.. 00058 // strip them off 00059 while (substr($ret, -2, -1) === "\\") { 00060 $str_failures = '-!()|@~"/^&'; 00061 if (strpos($str_failures, substr($ret, -1)) !== false) { 00062 $ret = substr($ret, 0, -2); 00063 } 00064 else { 00065 break; 00066 } 00067 } 00068 return $ret; 00069 }
The documentation for this class was generated from the following file:
- contributions/sphinx/model/drivers/sphinx/sqlbuilder/dbsqlbuilder.where.sphinx.cls.php