PHP Класс yii\sphinx\Command

A command object is usually created by calling [[Connection::createCommand()]]. The SQL statement it represents can be set via the [[sql]] property. To execute a non-query SQL (such as INSERT, REPLACE, DELETE, UPDATE), call [[execute()]]. To execute a SQL statement that returns result data set (such as SELECT, CALL SNIPPETS, CALL KEYWORDS), use [[queryAll()]], [[queryOne()]], [[queryColumn()]], [[queryScalar()]], or [[query()]]. For example, ~~~ $articles = $connection->createCommand("SELECT * FROM idx_article WHERE MATCH('programming')")->queryAll(); ~~~ Command supports SQL statement preparation and parameter binding just as Command does. Command also supports building SQL statements by providing methods such as [[insert()]], Command::update, etc. For example, ~~~ $connection->createCommand()->update('idx_article', [ 'genre_id' => 15, 'author_id' => 157, ])->execute(); ~~~ To build SELECT SQL statements, please use Query and QueryBuilder instead.
С версии: 2.0
Автор: Paul Klimov ([email protected])
Наследование: extends yii\db\Command
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$db the Sphinx connection that this command is associated with.

Открытые методы

Метод Описание
addColumn ( $table, $column, $type )
addForeignKey ( $name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null )
addPrimaryKey ( $name, $table, $columns )
alterColumn ( $table, $column, $type )
batchInsert ( string $index, array $columns, array $rows ) Creates a batch INSERT command.
batchReplace ( string $index, array $columns, array $rows ) Creates a batch REPLACE command.
bindValue ( $name, $value, $dataType = null )
bindValues ( $values )
callKeywords ( string $index, string $text, boolean $fetchStatistic = false ) Returns tokenized and normalized forms of the keywords, and, optionally, keyword statistics.
callSnippets ( string $index, string | array $source, string $match, array $options = [] ) Builds a snippet from provided data and query, using specified index settings.
checkIntegrity ( $check = true, $schema = '', $table = '' )
createIndex ( $name, $table, $columns, $unique = false )
createTable ( $table, $columns, $options = null )
dropColumn ( $table, $column )
dropForeignKey ( $name, $table )
dropIndex ( $name, $table )
dropPrimaryKey ( $name, $table )
dropTable ( $table )
prepare ( $forRead = null )
renameColumn ( $table, $oldName, $newName )
renameTable ( $table, $newName )
replace ( string $index, array $columns ) Creates an REPLACE command.
resetSequence ( $table, $value = null )
truncateIndex ( string $index ) Creates a SQL command for truncating a runtime index.
truncateTable ( $table )
update ( string $index, array $columns, string | array $condition = '', array $params = [], array $options = [] ) Creates an UPDATE command.

Приватные методы

Метод Описание
parseFloatParams ( string $sql ) : string Parses given SQL replacing bound [[floatParams]] with their values.

Описание методов

addColumn() публичный Метод

public addColumn ( $table, $column, $type )

addForeignKey() публичный Метод

public addForeignKey ( $name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null )

addPrimaryKey() публичный Метод

public addPrimaryKey ( $name, $table, $columns )

alterColumn() публичный Метод

public alterColumn ( $table, $column, $type )

batchInsert() публичный Метод

For example, php $connection->createCommand()->batchInsert('idx_user', ['name', 'age'], [ ['Tom', 30], ['Jane', 20], ['Linda', 25], ])->execute(); Note that the values in each row must match the corresponding column names.
public batchInsert ( string $index, array $columns, array $rows )
$index string the index that new rows will be inserted into.
$columns array the column names
$rows array the rows to be batch inserted into the index

batchReplace() публичный Метод

For example, php $connection->createCommand()->batchReplace('idx_user', ['name', 'age'], [ ['Tom', 30], ['Jane', 20], ['Linda', 25], ])->execute(); Note that the values in each row must match the corresponding column names.
public batchReplace ( string $index, array $columns, array $rows )
$index string the index that new rows will be replaced.
$columns array the column names
$rows array the rows to be batch replaced in the index

bindValue() публичный Метод

public bindValue ( $name, $value, $dataType = null )

bindValues() публичный Метод

public bindValues ( $values )

callKeywords() публичный Метод

Returns tokenized and normalized forms of the keywords, and, optionally, keyword statistics.
public callKeywords ( string $index, string $text, boolean $fetchStatistic = false )
$index string the name of the index from which to take the text processing settings
$text string the text to break down to keywords.
$fetchStatistic boolean whether to return document and hit occurrence statistics

callSnippets() публичный Метод

Builds a snippet from provided data and query, using specified index settings.
public callSnippets ( string $index, string | array $source, string $match, array $options = [] )
$index string name of the index, from which to take the text processing settings.
$source string | array is the source data to extract a snippet from. It could be either a single string or array of strings.
$match string the full-text query to build snippets for.
$options array list of options in format: optionName => optionValue

checkIntegrity() публичный Метод

public checkIntegrity ( $check = true, $schema = '', $table = '' )

createIndex() публичный Метод

public createIndex ( $name, $table, $columns, $unique = false )

createTable() публичный Метод

public createTable ( $table, $columns, $options = null )

dropColumn() публичный Метод

public dropColumn ( $table, $column )

dropForeignKey() публичный Метод

public dropForeignKey ( $name, $table )

dropIndex() публичный Метод

public dropIndex ( $name, $table )

dropPrimaryKey() публичный Метод

public dropPrimaryKey ( $name, $table )

dropTable() публичный Метод

public dropTable ( $table )

prepare() публичный Метод

public prepare ( $forRead = null )

renameColumn() публичный Метод

public renameColumn ( $table, $oldName, $newName )

renameTable() публичный Метод

public renameTable ( $table, $newName )

replace() публичный Метод

For example, php $connection->createCommand()->replace('idx_user', [ 'name' => 'Sam', 'age' => 30, ])->execute(); The method will properly escape the column names, and bind the values to be replaced. Note that the created command is not executed until [[execute()]] is called.
public replace ( string $index, array $columns )
$index string the index that new rows will be replaced into.
$columns array the column data (name => value) to be replaced into the index.

resetSequence() публичный Метод

public resetSequence ( $table, $value = null )

truncateIndex() публичный Метод

Creates a SQL command for truncating a runtime index.
public truncateIndex ( string $index )
$index string the index to be truncated. The name will be properly quoted by the method.

truncateTable() публичный Метод

public truncateTable ( $table )

update() публичный Метод

For example, php $connection->createCommand()->update('user', ['status' => 1], 'age > 30')->execute(); The method will properly escape the column names and bind the values to be updated. Note that the created command is not executed until [[execute()]] is called.
public update ( string $index, array $columns, string | array $condition = '', array $params = [], array $options = [] )
$index string the index to be updated.
$columns array the column data (name => value) to be updated.
$condition string | array the condition that will be put in the WHERE part. Please refer to [[Query::where()]] on how to specify condition.
$params array the parameters to be bound to the command
$options array list of options in format: optionName => optionValue

Описание свойств

$db публичное свойство

the Sphinx connection that this command is associated with.
public $db