没有命名空间的类 yii yii\base yii\behaviors yii\caching yii\captcha yii\console yii\console\controllers yii\console\widgets yii\data yii\db yii\db\conditions yii\db\cubrid yii\db\cubrid\conditions yii\db\mssql yii\db\mssql\conditions yii\db\mysql yii\db\oci yii\db\oci\conditions yii\db\pgsql yii\db\sqlite yii\db\sqlite\conditions yii\di yii\filters yii\filters\auth yii\grid yii\helpers yii\i18n yii\log yii\mail yii\mutex yii\rbac yii\rest yii\test yii\validators yii\web yii\widgets

Class yii\db\SqlToken

继承yii\db\SqlToken » yii\base\BaseObject
实现ArrayAccess, yii\base\Configurable
可用版本自2.0.13
源码 https://github.com/yiichina/yii2/blob/api/framework/db/SqlToken.php

SqlToken represents SQL tokens produced by yii\db\SqlTokenizer or its child classes.

公共属性

隐藏继承的属性

属性类型描述被定义在
$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

公共方法

隐藏继承的方法

方法描述被定义在
__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

常量

隐藏继承的常量

常量描述被定义在
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

属性详情

$children 公共 属性

Child tokens.

public yii\db\SqlToken[] getChildren ( )
public void setChildren ( $children )
$content 公共 属性

Token content.

public string|null $content null
$endOffset 公共 属性

Original SQL token end position.

public integer $endOffset null
$hasChildren 公共 只读 属性

Whether the token has children.

$isCollection 公共 只读 属性

Whether the token represents a collection of tokens.

$parent 公共 属性

Parent token.

public yii\db\SqlToken $parent null
$sql 公共 只读 属性

SQL code.

public string getSql ( )
$startOffset 公共 属性

Original SQL token start position.

public integer $startOffset null
$type 公共 属性
public integer $type self::TYPE_TOKEN

方法详情

__toString() 公共 方法

Returns the SQL code representing the token.

public string __toString()
return string

SQL code.

getChildren() 公共 方法

Returns child tokens.

public yii\db\SqlToken[] getChildren()
return yii\db\SqlToken[]

Child tokens.

getHasChildren() 公共 方法

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.

getIsCollection() 公共 方法

Returns whether the token represents a collection of tokens.

public boolean getIsCollection()
return boolean

Whether the token represents a collection of tokens.

getSql() 公共 方法

Returns the SQL code representing the token.

public string getSql()
return string

SQL code.

matches() 公共 方法

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 any keyword is supported which will match any number of keywords, identifiers, whitespaces.

$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.

offsetExists() 公共 方法

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.

offsetGet() 公共 方法

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, null if there's no token.

offsetSet() 公共 方法

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.

offsetUnset() 公共 方法

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.

setChildren() 公共 方法

Sets a list of child tokens.

public void setChildren($children)
$children yii\db\SqlToken[]

Child tokens.