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 |
---|---|---|
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
The Sphinx connection
All index names in the Sphinx.
The metadata for all indexes in the Sphinx. Each array element is an instance of yii\sphinx\IndexSchema or its child class.
All index types in the Sphinx in format: index name => index type.
The query builder for this connection.
Mapping from physical column types (keys) to abstract column types (values)
Method Details
Converts a DB exception to a more concrete one if possible.
yii\db\Exception convertException( \Exception $e, $rawSql ) | ||
$e | Exception | |
$rawSql | string | SQL that produced exception |
Creates a query builder for the Sphinx.
yii\sphinx\QueryBuilder createQueryBuilder( ) | ||
return | yii\sphinx\QueryBuilder | Query builder instance |
---|
Collects the metadata of index columns.
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.
array findIndexes( ) | ||
return | array | All index names in the Sphinx. |
---|
Returns the cache key for the specified index name.
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.
string getCacheTag( ) | ||
return | string | The cache tag name |
---|
Extracts the PHP type from abstract DB type.
string getColumnPhpType( $column ) | ||
$column | yii\sphinx\ColumnSchema | The column schema information |
return | string | PHP type name |
---|
Returns all index names in the Sphinx.
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.
yii\sphinx\IndexSchema 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 | Index metadata. Null if the named index does not exist. |
---|
Returns the metadata for all indexes in the database.
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.
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.
integer getPdoType( $data ) | ||
$data | mixed | The data whose PDO type is to be determined |
return | integer | The PDO type |
---|
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.
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.
void initIndexesInfo( ) |
Returns a value indicating whether a SQL statement is for read purpose.
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.
yii\sphinx\ColumnSchema loadColumnSchema( $info ) | ||
$info | array | Column information |
return | yii\sphinx\ColumnSchema | The column schema object |
---|
Loads the metadata for the specified index.
yii\sphinx\IndexSchema loadIndexSchema( $name ) | ||
$name | string | Index name |
return | yii\sphinx\IndexSchema | Driver dependent index metadata. Null if the index does not exist. |
---|
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().
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.
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.
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.
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.
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.
void refresh( ) |
Resolves the index name.
void resolveIndexNames( $index, $name ) | ||
$index | yii\sphinx\IndexSchema | The index metadata object |
$name | string | The index name |
Resolves the index name.
void resolveIndexType( $index ) | ||
$index | yii\sphinx\IndexSchema | The index metadata object |