Class yii\sphinx\ColumnSchema
Inheritance | yii\sphinx\ColumnSchema » yii\base\BaseObject |
---|---|
Available since extension's version | 2.0 |
Source Code | https://github.com/yiisoft/yii2-sphinx/blob/master/src/ColumnSchema.php |
ColumnSchema class describes the metadata of a column in a Sphinx index.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$dbType | string | The DB type of this column. | yii\sphinx\ColumnSchema |
$isAttribute | boolean | Whether this column is an attribute | yii\sphinx\ColumnSchema |
$isField | boolean | Whether this column is a indexed field | yii\sphinx\ColumnSchema |
$isMva | boolean | Whether this column is a multi value attribute (MVA) | yii\sphinx\ColumnSchema |
$isPrimaryKey | boolean | Whether this column is a primary key | yii\sphinx\ColumnSchema |
$name | string | Name of this column (without quotes). | yii\sphinx\ColumnSchema |
$phpType | string | The PHP type of this column. | yii\sphinx\ColumnSchema |
$type | string | Abstract type of this column. | yii\sphinx\ColumnSchema |
Public Methods
Method | Description | Defined By |
---|---|---|
dbTypecast() | Converts the input value according to $type and $dbType for use in a db query. | yii\sphinx\ColumnSchema |
phpTypecast() | Converts the input value according to $phpType after retrieval from the database. | yii\sphinx\ColumnSchema |
Protected Methods
Method | Description | Defined By |
---|---|---|
typecast() | Converts the input value according to $phpType after retrieval from the database. | yii\sphinx\ColumnSchema |
Property Details
The DB type of this column. Possible DB types vary according to the type of DBMS.
Whether this column is a multi value attribute (MVA)
Whether this column is a primary key
The PHP type of this column. Possible PHP types include: string, boolean, integer, double.
Method Details
Converts the input value according to $type and $dbType for use in a db query.
If the value is null or an Expression, it will not be converted.
public mixed dbTypecast ( $value ) | ||
$value | mixed |
Input value |
return | mixed |
Converted value. This may also be an array containing the value as the first element and the PDO type as the second element. |
---|
public function dbTypecast($value)
{
// the default implementation does the same as casting for PHP, but it should be possible
// to override this with annotation of explicit PDO type.
return $this->typecast($value);
}
Converts the input value according to $phpType after retrieval from the database.
If the value is null or an Expression, it will not be converted.
public mixed phpTypecast ( $value ) | ||
$value | mixed |
Input value |
return | mixed |
Converted value |
---|
public function phpTypecast($value)
{
return $this->typecast($value);
}
Converts the input value according to $phpType after retrieval from the database.
If the value is null or an Expression, it will not be converted.
protected mixed typecast ( $value ) | ||
$value | mixed |
Input value |
return | mixed |
Converted value |
---|
protected function typecast($value)
{
if ($value === '' && $this->type !== Schema::TYPE_STRING) {
return null;
}
if ($value === null || gettype($value) === $this->phpType || $value instanceof Expression) {
return $value;
}
switch ($this->phpType) {
case 'resource':
case 'string':
return is_resource($value) ? $value : (string) $value;
case 'int':
case 'integer':
return (int) $value;
case 'bool':
case 'boolean':
return (bool) $value;
case 'double':
return (double) $value;
}
return $value;
}