Class yii\db\SqlToken
| Inheritance | yii\db\SqlToken » yii\base\BaseObject |
|---|---|
| Implements | ArrayAccess, yii\base\Configurable |
| Available since version | 2.0.13 |
SqlToken represents SQL tokens produced by yii\db\SqlTokenizer or its child classes.
Public Properties
隐藏继承的属性 Hide inherited properties
| 属性Property | 类型 Type | 简介 Description | 定义在 Defined By |
|---|---|---|---|
| $children | yii\db\SqlToken[] | Child tokens. | yii\db\SqlToken |
| $content | string|null | Token content. | yii\db\SqlToken |
| $endOffset | integer | Original SQL token end position. | yii\db\SqlToken |
| $hasChildren | boolean | Whether the token has children. | yii\db\SqlToken |
| $isCollection | boolean | Whether the token represents a collection of tokens. | yii\db\SqlToken |
| $parent | yii\db\SqlToken | Parent token. | yii\db\SqlToken |
| $sql | string | SQL code. | yii\db\SqlToken |
| $startOffset | integer | Original SQL token start position. | yii\db\SqlToken |
| $type | integer | Token type. | yii\db\SqlToken |
Public Methods
隐藏继承的方法 Hide inherited 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 |
| __toString() | Returns the SQL code representing the token. | yii\db\SqlToken |
| __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 |
| getChildren() | Returns child tokens. | yii\db\SqlToken |
| getHasChildren() | Returns whether the token represents a collection of tokens and has non-zero number of children. | yii\db\SqlToken |
| getIsCollection() | Returns whether the token represents a collection of tokens. | yii\db\SqlToken |
| getSql() | Returns the SQL code representing the token. | yii\db\SqlToken |
| 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 |
| matches() | Returns whether this token (including its children) matches the specified "pattern" SQL code. | yii\db\SqlToken |
| offsetExists() | Returns whether there is a child token at the specified offset. | yii\db\SqlToken |
| offsetGet() | Returns a child token at the specified offset. | yii\db\SqlToken |
| offsetSet() | Adds a child token to the token. | yii\db\SqlToken |
| offsetUnset() | Removes a child token at the specified offset. | yii\db\SqlToken |
| setChildren() | Sets a list of child tokens. | yii\db\SqlToken |
常量 Constants
隐藏继承的常量 Hide inherited constants
| 常量 Constant | 值 Value | 简介 Description | 定义在 Defined By |
|---|---|---|---|
| TYPE_CODE | 0 | yii\db\SqlToken | |
| TYPE_IDENTIFIER | 6 | yii\db\SqlToken | |
| TYPE_KEYWORD | 4 | yii\db\SqlToken | |
| TYPE_OPERATOR | 5 | yii\db\SqlToken | |
| TYPE_PARENTHESIS | 3 | yii\db\SqlToken | |
| TYPE_STATEMENT | 1 | yii\db\SqlToken | |
| TYPE_STRING_LITERAL | 7 | yii\db\SqlToken | |
| TYPE_TOKEN | 2 | yii\db\SqlToken |
属性详情 Property Details
Child tokens.
Token content.
Original SQL token end position.
Whether the token has children.
Whether the token represents a collection of tokens.
Parent token.
SQL code.
Original SQL token start position.
Token type. It has to be one of the following constants:
方法详情 Method Details
Returns the SQL code representing the token.
| public string __toString ( ) | ||
| return | string | SQL code. |
|---|---|---|
Returns child tokens.
| public yii\db\SqlToken[] getChildren ( ) | ||
| return | yii\db\SqlToken[] | Child tokens. |
|---|---|---|
Returns whether the token represents a collection of tokens and has non-zero number of children.
| public boolean getHasChildren ( ) | ||
| return | boolean | Whether the token has children. |
|---|---|---|
Returns whether the token represents a collection of tokens.
| public boolean getIsCollection ( ) | ||
| return | boolean | Whether the token represents a collection of tokens. |
|---|---|---|
Returns the SQL code representing the token.
| public string getSql ( ) | ||
| return | string | SQL code. |
|---|---|---|
Returns whether this token (including its children) matches the specified "pattern" SQL code.
Usage Example:
$patternToken = (new \yii\db\sqlite\SqlTokenizer('SELECT any FROM any'))->tokenize();
if ($sqlToken->matches($patternToken, 0, $firstMatchIndex, $lastMatchIndex)) {
// ...
}
| public boolean matches ( yii\db\SqlToken $patternToken, $offset = 0, &$firstMatchIndex = null, &$lastMatchIndex = null ) | ||
| $patternToken | yii\db\SqlToken | Tokenized SQL code to match against. In addition to normal SQL, the
|
| $offset | integer | Token children offset to start lookup with. |
| $firstMatchIndex | integer|null | Token children offset where a successful match begins. |
| $lastMatchIndex | integer|null | Token children offset where a successful match ends. |
| return | boolean | Whether this token matches the pattern SQL code. |
|---|---|---|
Returns whether there is a child token at the specified offset.
This method is required by the SPL ArrayAccess interface.
It is implicitly called when you use something like isset($token[$offset]).
| public boolean offsetExists ( $offset ) | ||
| $offset | integer | Child token offset. |
| return | boolean | Whether the token exists. |
|---|---|---|
Returns a child token at the specified offset.
This method is required by the SPL ArrayAccess interface.
It is implicitly called when you use something like $child = $token[$offset];.
| public yii\db\SqlToken|null offsetGet ( $offset ) | ||
| $offset | integer | Child token offset. |
| return | yii\db\SqlToken|null | The child token at the specified offset, |
|---|---|---|
Adds a child token to the token.
This method is required by the SPL ArrayAccess interface.
It is implicitly called when you use something like $token[$offset] = $child;.
| public void offsetSet ( $offset, $token ) | ||
| $offset | integer|null | Child token offset. |
| $token | yii\db\SqlToken | Token to be added. |
Removes a child token at the specified offset.
This method is required by the SPL ArrayAccess interface.
It is implicitly called when you use something like unset($token[$offset]).
| public void offsetUnset ( $offset ) | ||
| $offset | integer | Child token offset. |
Sets a list of child tokens.
| public void setChildren ( $children ) | ||
| $children | yii\db\SqlToken[] | Child tokens. |