Class yii\sphinx\Schema
Inheritance | yii\sphinx\Schema » yii\base\BaseObject |
---|---|
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 |
$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\BaseObject |
__construct() | Constructor. | yii\base\BaseObject |
__get() | Returns the value of an object property. | yii\base\BaseObject |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\BaseObject |
__set() | Sets value of an object property. | yii\base\BaseObject |
__unset() | Sets an object property to null. | yii\base\BaseObject |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\BaseObject |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\BaseObject |
className() | Returns the fully qualified name of this class. | yii\base\BaseObject |
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\BaseObject |
hasProperty() | Returns a value indicating whether a property is defined. | yii\base\BaseObject |
init() | Initializes the object. | yii\base\BaseObject |
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 |
mergeColumnSchema() | Merges two column schemas into a single one. | 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
The Sphinx connection
Mapping from physical column types (keys) to abstract column types (values)
Method Details
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 |
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 |
Creates a query builder for the Sphinx.
public yii\sphinx\QueryBuilder createQueryBuilder ( ) | ||
return | yii\sphinx\QueryBuilder | Query builder instance |
---|
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 |
Returns all index names in the Sphinx.
protected array findIndexes ( ) | ||
return | array | All index names in the Sphinx. |
---|
Returns the cache key for the specified index name.
protected mixed getCacheKey ( $name ) | ||
$name | string | The index name |
return | mixed | The cache key |
---|
Returns the cache tag name.
This allows refresh() to invalidate all cached index schemas.
protected string getCacheTag ( ) | ||
return | string | The cache tag name |
---|
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 |
---|
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. |
---|
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. |
---|
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. |
---|
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. |
---|
Determines the PDO type for the given PHP data value.
public integer getPdoType ( $data ) | ||
$data | mixed | The data whose PDO type is to be determined |
return | integer | The PDO type |
---|
public yii\sphinx\QueryBuilder getQueryBuilder ( ) | ||
return | yii\sphinx\QueryBuilder | The query builder for this connection. |
---|
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 |
---|
Initializes information about name and type of all index in the Sphinx.
protected void initIndexesInfo ( ) |
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. |
---|
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 |
---|
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. |
---|
Merges two column schemas into a single one.
protected yii\sphinx\ColumnSchema mergeColumnSchema ( $origin, $override ) | ||
$origin | yii\sphinx\ColumnSchema | Original column schema. |
$override | yii\sphinx\ColumnSchema | Column schema to be applied over original one. |
return | yii\sphinx\ColumnSchema | Merge result. |
---|
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 |
---|
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 |
---|
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 |
---|
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 |
---|
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 |
---|
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 ( ) |
Resolves the index name.
protected void resolveIndexNames ( $index, $name ) | ||
$index | yii\sphinx\IndexSchema | The index metadata object |
$name | string | The index name |
Resolves the index name.
protected void resolveIndexType ( $index ) | ||
$index | yii\sphinx\IndexSchema | The index metadata object |