PHP Class yii\sphinx\Schema

Since: 2.0
Author: Paul Klimov ([email protected])
Inheritance: extends yii\base\Object
Datei anzeigen Open project: yiisoft/yii2-sphinx

Public Properties

Property Type Description
$db the Sphinx connection
$typeMap mapping from physical column types (keys) to abstract column types (values)

Public Methods

Method Description
convertException ( Exception $e, string $rawSql ) : Exception Converts a DB exception to a more concrete one if possible.
createQueryBuilder ( ) : QueryBuilder Creates a query builder for the Sphinx.
getIndexNames ( boolean $refresh = false ) : string[] Returns all index names in the Sphinx.
getIndexSchema ( string $name, boolean $refresh = false ) : IndexSchema | null Obtains the metadata for the named index.
getIndexSchemas ( boolean $refresh = false ) : IndexSchema[] Returns the metadata for all indexes in the database.
getIndexTypes ( boolean $refresh = false ) : array Returns all index types in the Sphinx.
getPdoType ( mixed $data ) : integer Determines the PDO type for the given PHP data value.
getQueryBuilder ( ) : QueryBuilder
getRawIndexName ( string $name ) : string Returns the actual name of a given index name.
isReadQuery ( string $sql ) : boolean Returns a value indicating whether a SQL statement is for read purpose.
quoteColumnName ( string $name ) : string Quotes a column name for use in a query.
quoteIndexName ( string $name ) : string Quotes a index name for use in a query.
quoteSimpleColumnName ( string $name ) : string Quotes a column name for use in a query.
quoteSimpleIndexName ( string $name ) : string Quotes a index name for use in a query.
quoteValue ( string $str ) : string Quotes a string value for use in a query.
refresh ( ) Refreshes the schema.

Protected Methods

Method Description
applyDefaultColumns ( IndexSchema $index ) Sets up the default columns for given index.
findColumns ( IndexSchema $index ) : boolean Collects the metadata of index columns.
findIndexes ( ) : array Returns all index names in the Sphinx.
getCacheKey ( string $name ) : mixed Returns the cache key for the specified index name.
getCacheTag ( ) : string Returns the cache tag name.
getColumnPhpType ( ColumnSchema $column ) : string Extracts the PHP type from abstract DB type.
initIndexesInfo ( ) Initializes information about name and type of all index in the Sphinx.
loadColumnSchema ( array $info ) : ColumnSchema Loads the column information into a ColumnSchema object.
loadIndexSchema ( string $name ) : IndexSchema | null Loads the metadata for the specified index.
resolveIndexNames ( IndexSchema $index, string $name ) Resolves the index name.
resolveIndexType ( IndexSchema $index ) Resolves the index name.

Method Details

applyDefaultColumns() protected method

This method should be used in case there is no way to find actual columns, like in some distributed indexes.
Since: 2.0.6
protected applyDefaultColumns ( IndexSchema $index )
$index IndexSchema the index metadata

convertException() public method

Converts a DB exception to a more concrete one if possible.
public convertException ( Exception $e, string $rawSql ) : Exception
$e Exception
$rawSql string SQL that produced exception
return yii\db\Exception

createQueryBuilder() public method

Creates a query builder for the Sphinx.
public createQueryBuilder ( ) : QueryBuilder
return QueryBuilder query builder instance

findColumns() protected method

Collects the metadata of index columns.
protected findColumns ( IndexSchema $index ) : boolean
$index IndexSchema the index metadata
return boolean whether the index exists in the database

findIndexes() protected method

Returns all index names in the Sphinx.
protected findIndexes ( ) : array
return array all index names in the Sphinx.

getCacheKey() protected method

Returns the cache key for the specified index name.
protected getCacheKey ( string $name ) : mixed
$name string the index name
return mixed the cache key

getCacheTag() protected method

This allows Schema::refresh to invalidate all cached index schemas.
protected getCacheTag ( ) : string
return string the cache tag name

getColumnPhpType() protected method

Extracts the PHP type from abstract DB type.
protected getColumnPhpType ( ColumnSchema $column ) : string
$column ColumnSchema the column schema information
return string PHP type name

getIndexNames() public method

Returns all index names in the Sphinx.
public getIndexNames ( boolean $refresh = false ) : string[]
$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 getIndexSchema ( string $name, boolean $refresh = false ) : IndexSchema | null
$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 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 getIndexSchemas ( boolean $refresh = false ) : IndexSchema[]
$refresh boolean whether to fetch the latest available index schemas. If this is false, cached data may be returned if available.
return IndexSchema[] the metadata for all indexes in the Sphinx. Each array element is an instance of [[IndexSchema]] or its child class.

getIndexTypes() public method

Returns all index types in the Sphinx.
public getIndexTypes ( boolean $refresh = false ) : array
$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 getPdoType ( mixed $data ) : integer
$data mixed the data whose PDO type is to be determined
return integer the PDO type

getQueryBuilder() public method

public getQueryBuilder ( ) : QueryBuilder
return QueryBuilder the query builder for this connection.

getRawIndexName() public method

This method will strip off curly brackets from the given index name and replace the percentage character '%' with [[Connection::indexPrefix]].
public getRawIndexName ( string $name ) : string
$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 initIndexesInfo ( )

isReadQuery() public method

Returns a value indicating whether a SQL statement is for read purpose.
public isReadQuery ( string $sql ) : boolean
$sql string the SQL statement
return boolean whether a SQL statement is for read purpose.

loadColumnSchema() protected method

Loads the column information into a ColumnSchema object.
protected loadColumnSchema ( array $info ) : ColumnSchema
$info array column information
return ColumnSchema the column schema object

loadIndexSchema() protected method

Loads the metadata for the specified index.
protected loadIndexSchema ( string $name ) : IndexSchema | null
$name string index name
return IndexSchema | null driver dependent index metadata. `null` - if the index does not exist.

quoteColumnName() public method

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 quoteColumnName ( string $name ) : string
$name string column name
return string the properly quoted column name

quoteIndexName() public method

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: quoteSimpleTableName
public quoteIndexName ( string $name ) : string
$name string index name
return string the properly quoted index name

quoteSimpleColumnName() public method

A simple column name has no prefix.
public quoteSimpleColumnName ( string $name ) : string
$name string column name
return string the properly quoted column name

quoteSimpleIndexName() public method

A simple index name has no schema prefix.
public quoteSimpleIndexName ( string $name ) : string
$name string index name
return string the properly quoted index name

quoteValue() public method

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 quoteValue ( string $str ) : string
$str string string to be quoted
return string the properly quoted string

refresh() public method

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

resolveIndexNames() protected method

Resolves the index name.
protected resolveIndexNames ( IndexSchema $index, string $name )
$index IndexSchema the index metadata object
$name string the index name

resolveIndexType() protected method

Resolves the index name.
protected resolveIndexType ( IndexSchema $index )
$index IndexSchema the index metadata object

Property Details

$db public_oe property

the Sphinx connection
public $db

$typeMap public_oe property

mapping from physical column types (keys) to abstract column types (values)
public $typeMap