PHP 클래스 yii\sphinx\Connection

This class uses PDO to maintain such connection. Note: although PDO supports numerous database drivers, this class supports only MySQL. In order to setup Sphinx "searchd" to support MySQL protocol following configuration should be added: searchd { listen = localhost:9306:mysql41 ... } The following example shows how to create a Connection instance and establish the Sphinx connection: php $connection = new \yii\db\Connection([ 'dsn' => 'mysql:host=127.0.0.1;port=9306;', 'username' => $username, 'password' => $password, ]); $connection->open(); After the Sphinx connection is established, one can execute SQL statements like the following: php $command = $connection->createCommand("SELECT * FROM idx_article WHERE MATCH('programming')"); $articles = $command->queryAll(); $command = $connection->createCommand('UPDATE idx_article SET status=2 WHERE id=1'); $command->execute(); For more information about how to perform various DB queries, please refer to Command. This class supports transactions exactly as "yii\db\Connection". Note: while this class extends "yii\db\Connection" some of its methods are not supported.
부터: 2.0
저자: Paul Klimov ([email protected])
상속: extends yii\db\Connection
파일 보기 프로젝트 열기: yiisoft/yii2-sphinx 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$enableFloatConversion whether to enable conversion of the float query params into the direct literal SQL insertion. This allows processing of the float values, since PDO does not provide specific param type for float binding, while Sphinx is unable to process float values passed as quoted strings.
$schemaMap

공개 메소드들

메소드 설명
createCommand ( string $sql = null, array $params = [] ) : Command Creates a command for execution.
escapeMatchValue ( string $str ) : string Escapes all special characters from 'MATCH' statement argument.
getIndexSchema ( string $name, boolean $refresh = false ) : IndexSchema Obtains the schema information for the named index.
getLastInsertID ( string $sequenceName = '' ) : string This method is not supported by Sphinx.
quoteIndexName ( string $name ) : string Quotes a index name for use in a query.
quoteTableName ( string $name ) : string Alias of Connection::quoteIndexName.

메소드 상세

createCommand() 공개 메소드

Creates a command for execution.
public createCommand ( string $sql = null, array $params = [] ) : Command
$sql string the SQL statement to be executed
$params array the parameters to be bound to the SQL statement
리턴 Command the Sphinx command

escapeMatchValue() 공개 메소드

Make sure you are using this method whenever composing 'MATCH' search statement. Note: this method does not perform quoting, you should place the result in the quotes an perform additional escaping for it manually, the best way to do it is using PDO parameter.
public escapeMatchValue ( string $str ) : string
$str string string to be escaped.
리턴 string the properly escaped string.

getIndexSchema() 공개 메소드

Obtains the schema information for the named index.
public getIndexSchema ( string $name, boolean $refresh = false ) : IndexSchema
$name string index name.
$refresh boolean whether to reload the table schema even if it is found in the cache.
리턴 IndexSchema index schema information. Null if the named index does not exist.

getLastInsertID() 공개 메소드

This method is not supported by Sphinx.
public getLastInsertID ( string $sequenceName = '' ) : string
$sequenceName string name of the sequence object
리턴 string the row ID of the last row inserted, or the last value retrieved from the sequence object

quoteIndexName() 공개 메소드

If the index name contains schema prefix, the prefix will also be properly quoted. If the index name is already quoted or contains special characters including '(', '[[' and '{{', then this method will do nothing.
public quoteIndexName ( string $name ) : string
$name string index name
리턴 string the properly quoted index name

quoteTableName() 공개 메소드

public quoteTableName ( string $name ) : string
$name string table name
리턴 string the properly quoted table name

프로퍼티 상세

$enableFloatConversion 공개적으로 프로퍼티

whether to enable conversion of the float query params into the direct literal SQL insertion. This allows processing of the float values, since PDO does not provide specific param type for float binding, while Sphinx is unable to process float values passed as quoted strings.
부터: 2.0.6
public $enableFloatConversion

$schemaMap 공개적으로 프로퍼티

public $schemaMap