.

DBWhereFulltext Class Reference
[Model]

A MySql fulltext where implementation. More...

Inheritance diagram for DBWhereFulltext:
DBWhere IDBWhere

List of all members.

Public Member Functions

  __construct (IDBTable $table, $column, $value, $threshold=0, $mode=IDBWhere::LOGIC_AND)
  Constructor.
  build_fulltext_match (IDBTable $table, $column, $value, $mode, $additions= '')
  Builds a full text match statement.
  get_match ()
  Returns matchc clause that can be used for relevance ordering.

Protected Member Functions

  build_fulltext_sql (IDBTable $table, $column, $value, $threshold, $mode)
  Build the sql fragement.

Protected Attributes

  $match

Detailed Description

A MySql fulltext where implementation.

Author:
Gerd Riesselmann

Definition at line 8 of file dbwherefulltext.cls.php.


Constructor & Destructor Documentation

DBWhereFulltext::__construct ( IDBTable table,
column,
value,
threshold = 0,
mode = IDBWhere::LOGIC_AND  
)

Constructor.

Parameters:
IDBTable  $table Table that contains column
string  $column Column to query upon, or a full sql where statement
mixed  $value Value(s) to use string Either IDBWhere::LOGIC_AND or IDBWhere::LOGIC_OR

Reimplemented from DBWhere.

Definition at line 24 of file dbwherefulltext.cls.php.

00024                                                                                                                  {
00025                 if (!is_array($value)) {
00026                         $value = String::explode_terms($value);
00027                 }
00028                 parent::__construct(
00029                         $table, 
00030                         $this->build_fulltext_sql($table, $column, $value, $threshold, $mode),
00031                         null,
00032                         null,
00033                         $mode
00034                 );
00035                 $this->match = $this->build_fulltext_match($table, $column, $value, $mode);
00036         }

Member Function Documentation

DBWhereFulltext::build_fulltext_match ( IDBTable table,
column,
value,
mode,
additions = ''  
)

Builds a full text match statement.

Parameters:
IDBTable  $table Table that contains column
string  $column Column to query upon, or a full sql where statement
array  $value Array of Tokens
enum  $mode Either IDBWhere::LOGIC_AND or IDBWhere::LOGIC_OR
string  $additions Additional commads like "IN BOOLEAN MODE"
Returns:
string

Definition at line 79 of file dbwherefulltext.cls.php.

00079                                                                                                        {
00080                 $where = "";
00081                 $fieldName = $this->prefix_table_name($column, $table);
00082                 foreach($value as $token) {
00083                         if (substr($token, 0, 1) !== "-" && $mode == self::LOGIC_AND)
00084                                 $where .= "+";
00085                                 
00086                         if (substr($token, -1) != "\"")
00087                                 $token .= "*";
00088                                 
00089                         $where .= $token . " ";
00090                 }
00091                 
00092                 return "(MATCH (" . $fieldName . ") AGAINST ('" . $table->get_table_driver()->escape($where) . "' " . $table->get_table_driver()->escape($additions) . "))";            
00093         }       
DBWhereFulltext::build_fulltext_sql ( IDBTable table,
column,
value,
threshold,
mode  
) [protected]

Build the sql fragement.

Parameters:
IDBTable  $table Table that contains column
string  $column Column to query upon, or a full sql where statement
array  $value Value(s) to use
float  $threshold Minimum relevance (ignored if 0)
string  $mode Either IDBWhere::LOGIC_AND or IDBWhere::LOGIC_OR
Returns:
string

Definition at line 57 of file dbwherefulltext.cls.php.

00057                                                                                                    {
00058                 $threshold = Cast::float($threshold);
00059                 $addition = 'IN BOOLEAN MODE';
00060                 $ret = '';
00061                 if ($threshold > 0) {
00062                         $addition = '';
00063                         $ret = ' > ' . $threshold;
00064                 }
00065                 $ret = $this->build_fulltext_match($table, $column, $value, $mode, $addition) . $ret;
00066                 return $ret;
00067         }
DBWhereFulltext::get_match (  ) 

Returns matchc clause that can be used for relevance ordering.

Returns:
string

Definition at line 43 of file dbwherefulltext.cls.php.

00043                                     {
00044                 return $this->match;
00045         }

Member Data Documentation

DBWhereFulltext::$match [protected]

Definition at line 14 of file dbwherefulltext.cls.php.


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