class InsertStatement extends Statement (View source)

INSERT statement.

INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [PARTITION (partition_name,...)] [(col_name,...)] {VALUES | VALUE} ({expr | DEFAULT},...),(...),... [ ON DUPLICATE KEY UPDATE col_name=expr [, col_name=expr] ... ]

or

INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [PARTITION (partition_name,...)] SET col_name={expr | DEFAULT}, ... [ ON DUPLICATE KEY UPDATE col_name=expr [, col_name=expr] ... ]

or

INSERT [LOW_PRIORITY | HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [PARTITION (partition_name,...)] [(col_name,...)] SELECT ... [ ON DUPLICATE KEY UPDATE col_name=expr [, col_name=expr] ... ]

Constants

protected ADD_CLAUSE

protected ADD_KEYWORD

Properties

static array<string,int|array<int,int|string>> $statementOptions

Options for INSERT statements.

static array $clauses

The clauses of this statement, in order.

from  Statement
OptionsArray|null $options

The options of this query.

from  Statement
int|null $first

The index of the first token used in this statement.

from  Statement
int|null $last

The index of the last token used in this statement.

from  Statement
IntoKeyword|null $into

Tables used as target for this statement.

ArrayObj[]|null $values

Values to be inserted.

SetOperation[]|null $set

If SET clause is present holds the SetOperation.

SelectStatement|null $select

If SELECT clause is present holds the SelectStatement.

WithStatement|null $with

If WITH CTE is present holds the WithStatement.

SetOperation[]|null $onDuplicateSet

If ON DUPLICATE KEY UPDATE clause is present holds the SetOperation.

Methods

__construct(Parser|null $parser = null, TokensList|null $list = null)

No description

string
build()

Builds the string representation of this statement.

void
parse(Parser $parser, TokensList $list)

No description

void
before(Parser $parser, TokensList $list, Token $token)

Function called before the token is processed.

void
after(Parser $parser, TokensList $list, Token $token)

Function called after the token was processed.

array
getClauses()

Gets the clauses of this statement.

string
__toString()

Builds the string representation of this statement.

bool
validateClauseOrder(Parser $parser, TokensList $list)

Validates the order of the clauses in parsed statement Ideally this should be called after successfully completing the parsing of each statement.

Details

__construct(Parser|null $parser = null, TokensList|null $list = null)

No description

Parameters

Parser|null $parser

the instance that requests parsing

TokensList|null $list

the list of tokens to be parsed

Exceptions

ParserException

string build()

Builds the string representation of this statement.

Return Value

string

void parse(Parser $parser, TokensList $list)

No description

Parameters

Parser $parser

the instance that requests parsing

TokensList $list

the list of tokens to be parsed

Return Value

void

void before(Parser $parser, TokensList $list, Token $token)

Function called before the token is processed.

Parameters

Parser $parser

the instance that requests parsing

TokensList $list

the list of tokens to be parsed

Token $token

the token that is being parsed

Return Value

void

void after(Parser $parser, TokensList $list, Token $token)

Function called after the token was processed.

Parameters

Parser $parser

the instance that requests parsing

TokensList $list

the list of tokens to be parsed

Token $token

the token that is being parsed

Return Value

void

array getClauses()

Gets the clauses of this statement.

Return Value

array

string __toString()

Builds the string representation of this statement.

Return Value

string

See also

static::build

bool validateClauseOrder(Parser $parser, TokensList $list)

Validates the order of the clauses in parsed statement Ideally this should be called after successfully completing the parsing of each statement.

Parameters

Parser $parser

the instance that requests parsing

TokensList $list

the list of tokens to be parsed

Return Value

bool

Exceptions

ParserException