W3cubDocs

/Yii 2.0

Class yii\sphinx\Schema

Inheritance yii\sphinx\Schema » yii\base\Object
Implements yii\base\Configurable
Available since version 2.0
Source Code https://github.com/yiisoft/yii2-sphinx/blob/master/Schema.php

Schema represents the Sphinx schema information.

Public Properties

Property Type Description Defined By
$db yii\sphinx\Connection The Sphinx connection yii\sphinx\Schema
$indexNames string[] All index names in the Sphinx. yii\sphinx\Schema
$indexSchemas yii\sphinx\IndexSchema[] The metadata for all indexes in the Sphinx. yii\sphinx\Schema
$indexTypes array All index types in the Sphinx in format: index name => index type. yii\sphinx\Schema
$queryBuilder yii\sphinx\QueryBuilder The query builder for this connection. yii\sphinx\Schema
$typeMap array Mapping from physical column types (keys) to abstract column types (values) yii\sphinx\Schema

Public Methods

Method Description Defined By
__call() Calls the named method which is not a class method. yii\base\Object
__construct() Constructor. yii\base\Object
__get() Returns the value of an object property. yii\base\Object
__isset() Checks if a property is set, i.e. defined and not null. yii\base\Object
__set() Sets value of an object property. yii\base\Object
__unset() Sets an object property to null. yii\base\Object
canGetProperty() Returns a value indicating whether a property can be read. yii\base\Object
canSetProperty() Returns a value indicating whether a property can be set. yii\base\Object
className() Returns the fully qualified name of this class. yii\base\Object
convertException() Converts a DB exception to a more concrete one if possible. yii\sphinx\Schema
createQueryBuilder() Creates a query builder for the Sphinx. yii\sphinx\Schema
getIndexNames() Returns all index names in the Sphinx. yii\sphinx\Schema
getIndexSchema() Obtains the metadata for the named index. yii\sphinx\Schema
getIndexSchemas() Returns the metadata for all indexes in the database. yii\sphinx\Schema
getIndexTypes() Returns all index types in the Sphinx. yii\sphinx\Schema
getPdoType() Determines the PDO type for the given PHP data value. yii\sphinx\Schema
getQueryBuilder() yii\sphinx\Schema
getRawIndexName() Returns the actual name of a given index name. yii\sphinx\Schema
hasMethod() Returns a value indicating whether a method is defined. yii\base\Object
hasProperty() Returns a value indicating whether a property is defined. yii\base\Object
init() Initializes the object. yii\base\Object
isReadQuery() Returns a value indicating whether a SQL statement is for read purpose. yii\sphinx\Schema
quoteColumnName() Quotes a column name for use in a query. yii\sphinx\Schema
quoteIndexName() Quotes a index name for use in a query. yii\sphinx\Schema
quoteSimpleColumnName() Quotes a column name for use in a query. yii\sphinx\Schema
quoteSimpleIndexName() Quotes a index name for use in a query. yii\sphinx\Schema
quoteValue() Quotes a string value for use in a query. yii\sphinx\Schema
refresh() Refreshes the schema. yii\sphinx\Schema

Protected Methods

Method Description Defined By
applyDefaultColumns() Sets up the default columns for given index. yii\sphinx\Schema
findColumns() Collects the metadata of index columns. yii\sphinx\Schema
findIndexes() Returns all index names in the Sphinx. yii\sphinx\Schema
getCacheKey() Returns the cache key for the specified index name. yii\sphinx\Schema
getCacheTag() Returns the cache tag name. yii\sphinx\Schema
getColumnPhpType() Extracts the PHP type from abstract DB type. yii\sphinx\Schema
initIndexesInfo() Initializes information about name and type of all index in the Sphinx. yii\sphinx\Schema
loadColumnSchema() Loads the column information into a yii\sphinx\ColumnSchema object. yii\sphinx\Schema
loadIndexSchema() Loads the metadata for the specified index. yii\sphinx\Schema
resolveIndexNames() Resolves the index name. yii\sphinx\Schema
resolveIndexType() Resolves the index name. yii\sphinx\Schema

Constants

Constant Value Description Defined By
TYPE_BIGINT 'bigint' yii\sphinx\Schema
TYPE_BOOLEAN 'boolean' yii\sphinx\Schema
TYPE_FLOAT 'float' yii\sphinx\Schema
TYPE_INTEGER 'integer' yii\sphinx\Schema
TYPE_PK 'pk' The following are the supported abstract column data types. yii\sphinx\Schema
TYPE_STRING 'string' yii\sphinx\Schema
TYPE_TIMESTAMP 'timestamp' yii\sphinx\Schema

Property Details

$db public property

The Sphinx connection

public yii\sphinx\Connection $db = null

$indexNames public read-only property

All index names in the Sphinx.

public string[] getIndexNames ( $refresh = false )

$indexSchemas public read-only property

The metadata for all indexes in the Sphinx. Each array element is an instance of yii\sphinx\IndexSchema or its child class.

public yii\sphinx\IndexSchema[] getIndexSchemas ( $refresh = false )

$indexTypes public read-only property

All index types in the Sphinx in format: index name => index type.

public array getIndexTypes ( $refresh = false )

$queryBuilder public read-only property

The query builder for this connection.

public yii\sphinx\QueryBuilder getQueryBuilder ( )

$typeMap public property

Mapping from physical column types (keys) to abstract column types (values)

public array $typeMap = ['field' => self::TYPE_STRING, 'string' => self::TYPE_STRING, 'ordinal' => self::TYPE_STRING, 'integer' => self::TYPE_INTEGER, 'int' => self::TYPE_INTEGER, 'uint' => self::TYPE_INTEGER, 'bigint' => self::TYPE_BIGINT, 'timestamp' => self::TYPE_TIMESTAMP, 'bool' => self::TYPE_BOOLEAN, 'float' => self::TYPE_FLOAT, 'mva' => self::TYPE_INTEGER]

Method Details

applyDefaultColumns() protected method (available since version 2.0.6)

Sets up the default columns for given index.

This method should be used in case there is no way to find actual columns, like in some distributed indexes.

protected void applyDefaultColumns ( $index )
$index yii\sphinx\IndexSchema

The index metadata

convertException() public method

Converts a DB exception to a more concrete one if possible.

public yii\db\Exception convertException ( Exception $e, $rawSql )
$e Exception
$rawSql string

SQL that produced exception

createQueryBuilder() public method

Creates a query builder for the Sphinx.

public yii\sphinx\QueryBuilder createQueryBuilder ( )
return yii\sphinx\QueryBuilder

Query builder instance

findColumns() protected method

Collects the metadata of index columns.

protected boolean findColumns ( $index )
$index yii\sphinx\IndexSchema

The index metadata

return boolean

Whether the index exists in the database

throws Exception

if DB query fails

findIndexes() protected method

Returns all index names in the Sphinx.

protected array findIndexes ( )
return array

All index names in the Sphinx.

getCacheKey() protected method

Returns the cache key for the specified index name.

protected mixed getCacheKey ( $name )
$name string

The index name

return mixed

The cache key

getCacheTag() protected method

Returns the cache tag name.

This allows refresh() to invalidate all cached index schemas.

protected string getCacheTag ( )
return string

The cache tag name

getColumnPhpType() protected method

Extracts the PHP type from abstract DB type.

protected string getColumnPhpType ( $column )
$column yii\sphinx\ColumnSchema

The column schema information

return string

PHP type name

getIndexNames() public method

Returns all index names in the Sphinx.

public string[] getIndexNames ( $refresh = false )
$refresh boolean

Whether to fetch the latest available index names. If this is false, index names fetched previously (if available) will be returned.

return string[]

All index names in the Sphinx.

getIndexSchema() public method

Obtains the metadata for the named index.

public yii\sphinx\IndexSchema|null getIndexSchema ( $name, $refresh = false )
$name string

Index name. The index name may contain schema name if any. Do not quote the index name.

$refresh boolean

Whether to reload the index schema even if it is found in the cache.

return yii\sphinx\IndexSchema|null

Index metadata. null - if the named index does not exist.

getIndexSchemas() public method

Returns the metadata for all indexes in the database.

public yii\sphinx\IndexSchema[] getIndexSchemas ( $refresh = false )
$refresh boolean

Whether to fetch the latest available index schemas. If this is false, cached data may be returned if available.

return yii\sphinx\IndexSchema[]

The metadata for all indexes in the Sphinx. Each array element is an instance of yii\sphinx\IndexSchema or its child class.

getIndexTypes() public method

Returns all index types in the Sphinx.

public array getIndexTypes ( $refresh = false )
$refresh boolean

Whether to fetch the latest available index types. If this is false, index types fetched previously (if available) will be returned.

return array

All index types in the Sphinx in format: index name => index type.

getPdoType() public method

Determines the PDO type for the given PHP data value.

See also http://www.php.net/manual/en/pdo.constants.php.

public integer getPdoType ( $data )
$data mixed

The data whose PDO type is to be determined

return integer

The PDO type

getQueryBuilder() public method

public yii\sphinx\QueryBuilder getQueryBuilder ( )
return yii\sphinx\QueryBuilder

The query builder for this connection.

getRawIndexName() public method

Returns the actual name of a given index name.

This method will strip off curly brackets from the given index name and replace the percentage character '%' with yii\sphinx\Connection::indexPrefix.

public string getRawIndexName ( $name )
$name string

The index name to be converted

return string

The real name of the given index name

initIndexesInfo() protected method

Initializes information about name and type of all index in the Sphinx.

protected void initIndexesInfo ( )

isReadQuery() public method

Returns a value indicating whether a SQL statement is for read purpose.

public boolean isReadQuery ( $sql )
$sql string

The SQL statement

return boolean

Whether a SQL statement is for read purpose.

loadColumnSchema() protected method

Loads the column information into a yii\sphinx\ColumnSchema object.

protected yii\sphinx\ColumnSchema loadColumnSchema ( $info )
$info array

Column information

return yii\sphinx\ColumnSchema

The column schema object

loadIndexSchema() protected method

Loads the metadata for the specified index.

protected yii\sphinx\IndexSchema|null loadIndexSchema ( $name )
$name string

Index name

return yii\sphinx\IndexSchema|null

Driver dependent index metadata. null - if the index does not exist.

quoteColumnName() public method

Quotes a column name for use in a query.

If the column name contains prefix, the prefix will also be properly quoted. If the column name is already quoted or contains '(', '[[' or '{{', then this method will do nothing.

See also quoteSimpleColumnName().

public string quoteColumnName ( $name )
$name string

Column name

return string

The properly quoted column name

quoteIndexName() public method

Quotes a index name for use in a query.

If the index name contains schema prefix, the prefix will also be properly quoted. If the index name is already quoted or contains '(' or '{{', then this method will do nothing.

See also \yii\sphinx\quoteSimpleTableName.

public string quoteIndexName ( $name )
$name string

Index name

return string

The properly quoted index name

quoteSimpleColumnName() public method

Quotes a column name for use in a query.

A simple column name has no prefix.

public string quoteSimpleColumnName ( $name )
$name string

Column name

return string

The properly quoted column name

quoteSimpleIndexName() public method

Quotes a index name for use in a query.

A simple index name has no schema prefix.

public string quoteSimpleIndexName ( $name )
$name string

Index name

return string

The properly quoted index name

quoteValue() public method

Quotes a string value for use in a query.

Note that if the parameter is not a string, it will be returned without change.

See also http://www.php.net/manual/en/function.PDO-quote.php.

public string quoteValue ( $str )
$str string

String to be quoted

return string

The properly quoted string

refresh() public method

Refreshes the schema.

This method cleans up all cached index schemas so that they can be re-created later to reflect the Sphinx schema change.

public void refresh ( )

resolveIndexNames() protected method

Resolves the index name.

protected void resolveIndexNames ( $index, $name )
$index yii\sphinx\IndexSchema

The index metadata object

$name string

The index name

resolveIndexType() protected method

Resolves the index name.

protected void resolveIndexType ( $index )
$index yii\sphinx\IndexSchema

The index metadata object

© 2008–2017 by Yii Software LLC
Licensed under the three clause BSD license.
http://www.yiiframework.com/doc-2.0/yii-sphinx-schema.html