.

DBSqlBuilderSelectSphinx Class Reference
[Sphinx]

Select Query Builder for Sphinx. More...

Inheritance diagram for DBSqlBuilderSelectSphinx:
DBSqlBuilderSelect DBSqlBuilderBase IDBSqlBuilder DBSqlBuilderCountSphinx

List of all members.

Public Member Functions

  get_sql ()
  Return SQL fragment.

Protected Member Functions

  get_features ($query)
  returns features
  get_fieldnames ($arr_fields, IDBTable $table)
  Returns names of fields to select as string.
  get_limit ($arr_limit)
  Return limit as string.
  get_order_by ($arr_orders)
  returns order by clause
  get_where (IDBWhere $where)
  Returns al whers transformed to a string.
  prefix_column ($column, $table)
  Prefix column with table alias.

Detailed Description

Select Query Builder for Sphinx.

Author:
Gerd Riesselmann

Definition at line 8 of file dbsqlbuilder.select.sphinx.cls.php.


Member Function Documentation

DBSqlBuilderSelectSphinx::get_features ( query  )  [protected]

returns features

Returns:
array

Reimplemented in DBSqlBuilderCountSphinx.

Definition at line 103 of file dbsqlbuilder.select.sphinx.cls.php.

00103                                                 {
00104                 $ret = array();
00105                 if (isset($query->sphinx_features)) {
00106                         $ret = $query->sphinx_features;
00107                 }
00108                 return $ret;
00109         }
DBSqlBuilderSelectSphinx::get_fieldnames ( arr_fields,
IDBTable table  
) [protected]

Returns names of fields to select as string.

Reimplemented from DBSqlBuilderSelect.

Definition at line 41 of file dbsqlbuilder.select.sphinx.cls.php.

00041                                                                         {
00042                 $ret = '';
00043                 $fieldnames = array();
00044                 foreach($arr_fields as $key => $name) {
00045                         $has_alias = !is_numeric($key);
00046                         $fieldname = $has_alias ? $key : $name;
00047                         $fieldalias = $name;
00048 
00049                         $statement = $this->prefix_column($fieldname, $table);
00050                         if ($fieldalias != '*') {
00051                                 $statement .=  ' AS ' . DB::escape_database_entity($fieldalias, $table->get_table_driver(), IDBDriver::ALIAS);
00052                         }
00053                         
00054                         $fieldnames[] = $statement;
00055                 }
00056                 if (count($fieldnames)) {
00057                         $ret = implode(', ', $fieldnames);
00058                 }
00059                 else {
00060                         $ret = $this->prefix_column('*', $table);
00061                 }
00062                 return $ret;
00063         }
DBSqlBuilderSelectSphinx::get_limit ( arr_limit  )  [protected]

Return limit as string.

Reimplemented from DBSqlBuilderBase.

Reimplemented in DBSqlBuilderCountSphinx.

Definition at line 68 of file dbsqlbuilder.select.sphinx.cls.php.

00068                                                  {
00069                 $arr_limit = array_map('intval', $arr_limit);
00070                 $ret = '';
00071                 if ($arr_limit[1] > 0) {
00072                         $ret = $arr_limit[0] . ';' . $arr_limit[1];
00073                 }
00074                 return $ret;
00075         }
DBSqlBuilderSelectSphinx::get_order_by ( arr_orders  )  [protected]

returns order by clause

Reimplemented from DBSqlBuilderBase.

Definition at line 80 of file dbsqlbuilder.select.sphinx.cls.php.

00080                                                      {
00081                 $ret = '';
00082                 if (count($arr_orders) > 0) {
00083                         $items = array();
00084                         foreach($arr_orders as $order) {
00085                                 $column = Arr::get_item($order, 'field', '');
00086                                 if (empty($column)) {
00087                                         continue;
00088                                 }
00089                                 $table =  Arr::get_item($order, 'table', null);
00090                                 $direction = Arr::get_item($order, 'direction', 'ASC');
00091                                 $items[] = $column. ' ' . $direction;
00092                         }
00093                         $ret .= implode(', ', $items);
00094                 }
00095                 return $ret;
00096         }
DBSqlBuilderSelectSphinx::get_sql (  ) 

Return SQL fragment.

Returns:
string

Reimplemented from DBSqlBuilderBase.

Definition at line 14 of file dbsqlbuilder.select.sphinx.cls.php.

00014                                   {
00015                 $table = $this->query->get_table();
00016                 return serialize(
00017                         array(
00018                                 'conditions' => $this->get_where($this->query->get_wheres()),
00019                                 'fields' => $this->get_fieldnames($this->fields, $table),
00020                                 'from' => $this->get_table($table),
00021                                 'limit' => $this->get_limit(Arr::get_item($this->params, 'limit', array(0,0))),
00022                                 'order' => $this->get_order_by(Arr::get_item($this->params, 'order_by', array())),
00023                                 'features' => $this->get_features($this->query)
00024                         )
00025                 ); 
00026                 // 'SELECT%distinct %!fields FROM %!from%join%where%group_by%having%order_by%limit%for_update';
00027         }
DBSqlBuilderSelectSphinx::get_where ( IDBWhere where  )  [protected]

Returns al whers transformed to a string.

See also:
core/model/base/DBSqlBuilderBaseget_where($where)

Reimplemented from DBSqlBuilderBase.

Definition at line 34 of file dbsqlbuilder.select.sphinx.cls.php.

00034                                                       {
00035                 return $where->get_sql();
00036         }
DBSqlBuilderSelectSphinx::prefix_column ( column,
table  
) [protected]

Prefix column with table alias.

Parameters:
string  $column
IDBTable  | string $table
Returns:
string

Reimplemented from DBSqlBuilderBase.

Definition at line 118 of file dbsqlbuilder.select.sphinx.cls.php.

00118                                                           {
00119                 return DB::escape_database_entity($column, $table->get_table_driver(), IDBDriver::FIELD);
00120         }       

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