PHP 클래스 yii\sphinx\MatchExpression

In conjunction with MatchBuilder this class provides ability to build sophisticated MATCH expressions. Instance of this class can be passed to [[Query::match()]]. For example: php use yii\sphinx\Query; use yii\sphinx\MatchExpression; $rows = (new Query()) ->match(new MatchExpression('@title :title', ['title' => 'Yii'])) ->all(); You may use MatchExpression::match, MatchExpression::andMatch and MatchExpression::orMatch to combine several conditions. For example: php use yii\sphinx\Query; use yii\sphinx\MatchExpression; $rows = (new Query()) ->match( produces '((@title "Yii") (@author "Paul")) | (@content "Sphinx")' : (new MatchExpression()) ->match(['title' => 'Yii']) ->andMatch(['author' => 'Paul']) ->orMatch(['content' => 'Sphinx']) ) ->all(); You may as well compose expressions with special operators like 'MAYBE', 'PROXIMITY' etc. For example: php use yii\sphinx\Query; use yii\sphinx\MatchExpression; $rows = (new Query()) ->match( produces '@title "Yii" MAYBE "Sphinx"' : (new MatchExpression())->match([ 'maybe', 'title', 'Yii', 'Sphinx', ]) ) ->all(); $rows = (new Query()) ->match( produces '@title "Yii"~10' : (new MatchExpression())->match([ 'proximity', 'title', 'Yii', 10, ]) ) ->all(); Note: parameters passed via [[params]] or generated from array conditions will be automatically escaped using [[Connection::escapeMatchValue()]].
또한 보기: MatchBuilder
또한 보기: http://sphinxsearch.com/docs/current.html#extended-syntax
부터: 2.0.6
저자: Paul Klimov ([email protected])
상속: extends yii\base\Object
파일 보기 프로젝트 열기: yiisoft/yii2-sphinx

공개 프로퍼티들

프로퍼티 타입 설명
$match MATCH expression. For example: ['title' => 'Yii', 'content' => 'Sphinx']. Note: being specified as a plain string this value will not be quoted or escaped, do not pass possible unsecured values (like the ones obtained from HTTP request) as a direct value.
$params list of match expression parameter values indexed by parameter placeholders. For example, [':name' => 'Dan', ':age' => 31]. These parameters will be automatically escaped using [[Connection::escapeMatchValue()]] and inserted into MATCH expression as a quoted strings.

공개 메소드들

메소드 설명
__construct ( string $match = null, array $params = [], array $config = [] ) Constructor.
addParams ( array $params ) Adds additional parameters to be parsed into the query.
andMatch ( string | array | yii\db\Expression $condition, array $params = [] ) Adds an additional MATCH condition to the existing one.
match ( string | array | yii\db\Expression $condition, array $params = [] ) Sets the MATCH expression.
orMatch ( string | array | yii\db\Expression $condition, array $params = [] ) Adds an additional MATCH condition to the existing one.
params ( array $params ) Sets the parameters to be parsed into the query.

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( string $match = null, array $params = [], array $config = [] )
$match string the MATCH expression
$params array expression parameters.
$config array name-value pairs that will be used to initialize the object properties

addParams() 공개 메소드

Adds additional parameters to be parsed into the query.
또한 보기: params()
public addParams ( array $params )
$params array list of expression parameter values indexed by parameter placeholders. For example, `[':name' => 'Dan', ':age' => 31]`.

andMatch() 공개 메소드

The new condition and the existing one will be joined using the 'AND' (' ') operator.
또한 보기: match()
또한 보기: orMatch()
public andMatch ( string | array | yii\db\Expression $condition, array $params = [] )
$condition string | array | yii\db\Expression the new MATCH condition. Please refer to [[match()]] on how to specify this parameter.
$params array the parameters (name => value) to be parsed into the query.

match() 공개 메소드

The method requires a $condition parameter, and optionally a $params parameter specifying the values to be parsed into the expression. The $condition parameter should be either a string (e.g. '@name "John"') or an array.
또한 보기: andMatch()
또한 보기: orMatch()
public match ( string | array | yii\db\Expression $condition, array $params = [] )
$condition string | array | yii\db\Expression the conditions that should be put in the MATCH expression.
$params array the parameters (name => value) to be parsed into the query.

orMatch() 공개 메소드

The new condition and the existing one will be joined using the 'OR' ('|') operator.
또한 보기: match()
또한 보기: andMatch()
public orMatch ( string | array | yii\db\Expression $condition, array $params = [] )
$condition string | array | yii\db\Expression the new WHERE condition. Please refer to [[match()]] on how to specify this parameter.
$params array the parameters (name => value) to be parsed into the query.

params() 공개 메소드

Sets the parameters to be parsed into the query.
또한 보기: addParams()
public params ( array $params )
$params array list of expression parameter values indexed by parameter placeholders. For example, `[':name' => 'Dan', ':age' => 31]`.

프로퍼티 상세

$match 공개적으로 프로퍼티

MATCH expression. For example: ['title' => 'Yii', 'content' => 'Sphinx']. Note: being specified as a plain string this value will not be quoted or escaped, do not pass possible unsecured values (like the ones obtained from HTTP request) as a direct value.
또한 보기: match()
public $match

$params 공개적으로 프로퍼티

list of match expression parameter values indexed by parameter placeholders. For example, [':name' => 'Dan', ':age' => 31]. These parameters will be automatically escaped using [[Connection::escapeMatchValue()]] and inserted into MATCH expression as a quoted strings.
public $params