PHP Class yii\sphinx\Schema

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

Méthodes publiques

Свойство Type Description
$db the Sphinx connection
$typeMap mapping from physical column types (keys) to abstract column types (values)

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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 méthode

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 méthode

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
Résultat yii\db\Exception

createQueryBuilder() public méthode

Creates a query builder for the Sphinx.
public createQueryBuilder ( ) : QueryBuilder
Résultat QueryBuilder query builder instance

findColumns() protected méthode

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

findIndexes() protected méthode

Returns all index names in the Sphinx.
protected findIndexes ( ) : array
Résultat array all index names in the Sphinx.

getCacheKey() protected méthode

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

getCacheTag() protected méthode

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

getColumnPhpType() protected méthode

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

getIndexNames() public méthode

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.
Résultat string[] all index names in the Sphinx.

getIndexSchema() public méthode

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.
Résultat IndexSchema | null index metadata. `null` - if the named index does not exist.

getIndexSchemas() public méthode

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.
Résultat IndexSchema[] the metadata for all indexes in the Sphinx. Each array element is an instance of [[IndexSchema]] or its child class.

getIndexTypes() public méthode

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.
Résultat array all index types in the Sphinx in format: index name => index type.

getPdoType() public méthode

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
Résultat integer the PDO type

getQueryBuilder() public méthode

public getQueryBuilder ( ) : QueryBuilder
Résultat QueryBuilder the query builder for this connection.

getRawIndexName() public méthode

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
Résultat string the real name of the given index name

initIndexesInfo() protected méthode

Initializes information about name and type of all index in the Sphinx.
protected initIndexesInfo ( )

isReadQuery() public méthode

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

loadColumnSchema() protected méthode

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

loadIndexSchema() protected méthode

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

quoteColumnName() public méthode

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
Résultat string the properly quoted column name

quoteIndexName() public méthode

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
Résultat string the properly quoted index name

quoteSimpleColumnName() public méthode

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

quoteSimpleIndexName() public méthode

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

quoteValue() public méthode

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
Résultat string the properly quoted string

refresh() public méthode

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 méthode

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

resolveIndexType() protected méthode

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