a-blog cms PHP API Reference

SQL_BulkInsert extends SQL
in package

SQL_BulkInsert

SQLヘルパのBulkInsertメソッド群です。
メソッドの外で,条件対象のテーブルが選択されている必要があります

Table of Contents

Properties

$_columns  : array<string|int, string>
$_insert  : array<int, array<string, scalar|null>>
$_table  : string|null
$connection  : Connection
$result  : mixed

Methods

__construct()  : mixed
addColumn()  : bool
指定されたカラムをINSERT句に追加する
addInsert()  : bool
指定されたデータをINSERT句に追加する
aliasPlaceholders()  : array<string|int, mixed>
SQL文中のプレースホルダーとparamsのキーにprefixをつける
currval()  : array{sql: string, params: list|array}
指定されたsequence fieldの現在のシーケンス番号を返す<br> SQL::currval('entry_id', dsn())<br> SELECT sequence_entry_id FROM acms_sequence
delete()  : array{sql: string, params: list|array}
Where句を指定してDelete句を生成する為のSQL文を返す
dumpSQL()  : string
プレースホルダ付きSQLとparams配列から、デバッグ用のSQLを生成する
get()  : array{sql: string, params: list|array}
SQL文とパラメータを取得するメソッドです。
getParams()  : array<string, mixed>
SQL文のパラメータを取得するメソッドです。
getSQL()  : string
SQL文を取得するメソッドです。
hasData()  : bool
データがセットされているかどうかを確認します
isClass()  : bool
第一引数の値が特定の クラス のオブジェクトのインスタンスであるかどうかを判定
newBulkInsert()  : SQL_BulkInsert
TABLEを指定してINSERT句(バルク)を生成する為のSQL_BulkInsertを返す
newCase()  : SQL_Field_Case
CASE文を作成するためのSQL_Field_Caseオブジェクトを生成する <br /> $case = SQL::newCase();<br> $case->add(SQL::newOpr('entry_status', 'draft' '='), '下書き');<br> $case->add(SQL::newOpr('entry_status', 'open' '='), '公開');<br> $case->add(SQL::newOpr('entry_status', 'close' '='), '非公開');<br> $case->setElse('下書き');<br> CASE<br> WHEN entry_status = 'draft' THEN '下書き'<br> WHEN entry_status = 'open' THEN '公開'<br> WHEN entry_status = 'close' THEN '非公開'<br> ELSE '下書き'
newDelete()  : SQL_Delete
TABLEを指定してDELETE句を生成する為のSQL_Deleteを返す
newField()  : SQL_Field
SQL_Fieldオブジェクトを生成する<br> SQL::newField('entry_title', 'entry')<br> entry.entry_title
newFunction()  : SQL_Field_Function
関数を生成するためのSQL_Field_Functionオブジェクトを生成する<br> $funcに配列を指定すると、添字0を関数名、添字1以降を関数の引数として渡される<br> SQL::newFunction('entry_title', ['SUBSTR', 0, 10])<br> SUBSTR(entry_title, 0, 10)<br>
newGeometry()  : SQL_Field_Function
SQLのGeometry関数を作成するためのSQL_Field_Functionオブジェクトを生成する
newInsert()  : SQL_Insert
TABLEを指定してINSERT句を生成する為のSQL_Insertを返す
newInsertOrUpdate()  : SQL_InsertOrUpdate
TABLEを指定してINSERT ON DUPLICATE KEY UPDATE句を生成する為のSQL_InsertOrUpdateを返す
newOpr()  : mixed
演算子を生成するためのSQL_Field_Operatorオブジェクトを生成する<br> SQL::newOpr('entry_id', 1, '>')<br> entry_id > 1
newOprBw()  : SQL_Field_Operator_Between<string|int, T>
BETWEEN演算子を作成するためのSQL_Field_Operator_Betweenオブジェクトを生成する<br> SQL::newOprBw('entry_id', 1, 10)<br> entry_id BETWEEN 1 AND 10
newOprExists()  : SQL_Field_Operator_Exists
EXISTS演算子を作成するためのSQL_Field_Operator_Existsオブジェクトを生成する<br> SQL::newOprExists(SQL::newSelect('entry'))<br> EXISTS (SELECT * FROM acms_entry)
newOprIn()  : SQL_Field_Operator_In
IN演算子を作成するためのSQL_Field_Operator_Inオブジェクトを生成する<br> SQL::newOprIn('entry_id', [1, 2, 3, 4, 5])<br> entry_id IN (1, 2, 3, 4, 5)
newOprNotExists()  : SQL_Field_Operator_Exists
NOT EXISTS演算子を作成するためのSQL_Field_Operator_Existsオブジェクトを生成する <br> SQL::newOprExists(SQL::newSelect('entry'))<br> NOT EXISTS (SELECT * FROM acms_entry)
newOprNotIn()  : SQL_Field_Operator_In
NOT IN演算子を作成するためのSQL_Field_Operator_Inオブジェクトを生成する<br> SQL::newOprNotIn('entry_id', [1, 2, 3, 4, 5])<br> entry_id NOT IN (1, 2, 3, 4, 5)
newReplace()  : SQL_Replace
TABLEを指定してREPLACE句を生成する為のSQL_Replaceを返す
newSelect()  : SQL_Select
TABLEを指定してSELECT句を生成する為のSQL_Selectを返す
newSeq()  : SQL_Sequence
SQL_Sequenceオブジェクトを生成する
newUpdate()  : SQL_Update
TABLEを指定してUPDATE句を生成する為のSQL_Updateを返す
newWhere()  : SQL_Where
WHERE句を生成するためのSQL_Whereオブジェクトを生成する
nextval()  : array{sql: string, params: list|array}
指定されたsequence fieldのシーケンス番号を1進めてその値を返す<br> SQL::nextval('entry_id', dsn())<br> UPDATE acms_sequence SET sequence_entry_id = ( LAST_INSERT_ID(sequence_entry_id + 1) )
optimizeSeq()  : array{sql: string, params: list|array}
指定されたsequence fieldのシーケンス番号を最適化する<br> SQL::optimizeSeq('entry_id', dsn())<br> UPDATE acms_sequence SET sequence_entry_id = ( LAST_INSERT_ID(sequence_entry_id + 1) )
quoteKey()  : string
SQL文のキーを安全に引用符で囲むメソッドです。
safePlaceholder()  : string
プレースホルダ名を安全に生成する
setColumns()  : bool
指定されたカラムをINSERT句にセットする
setConnection()  : void
データベース接続を設定するメソッドです。
setTable()  : void
setval()  : array{sql: string, params: list|array}
指定されたsequence fieldを指定された値にセットする<br> SQL::setval('entry_id', 10, dsn())<br> UPDATE acms_sequence SET sequence_entry_id = 10
showTable()  : SQL_ShowTable
TABLEを指定してSHOW TABLE句を生成する為のSQL_ShowTableを返す

Properties

$_columns

public array<string|int, string> $_columns = []

$_insert

public array<int, array<string, scalar|null>> $_insert = []

$connection

protected static Connection $connection = \null

$result

protected mixed $result = \null

Methods

__construct()

public __construct([SQL|null $SQL = null ]) : mixed
Parameters
$SQL : SQL|null = null

addColumn()

指定されたカラムをINSERT句に追加する

public addColumn(string $column) : bool
Parameters
$column : string
Return values
bool

addInsert()

指定されたデータをINSERT句に追加する

public addInsert(array<string, scalar|null> $data) : bool
Parameters
$data : array<string, scalar|null>
Return values
bool

aliasPlaceholders()

SQL文中のプレースホルダーとparamsのキーにprefixをつける

public static aliasPlaceholders(string $sql, array<string|int, mixed> $params, string $prefix) : array<string|int, mixed>
Parameters
$sql : string

元のSQL文

$params : array<string|int, mixed>

元のパラメータ(:name → 値)

$prefix : string

プレフィックス(例: 'when_0_')

Return values
array<string|int, mixed>

[$newSql, $newParams]

currval()

指定されたsequence fieldの現在のシーケンス番号を返す<br> SQL::currval('entry_id', dsn())<br> SELECT sequence_entry_id FROM acms_sequence

public static currval(string|SQL_Sequence $seq[, Dsn|null $dsn = null ][, bool $plugin = false ]) : array{sql: string, params: list|array}
Parameters
$seq : string|SQL_Sequence
$dsn : Dsn|null = null
$plugin : bool = false
Tags
static
Return values
array{sql: string, params: list|array}

delete()

Where句を指定してDelete句を生成する為のSQL文を返す

public static delete(string|null $tb[, SQL_Where|null $w = null ][, Dsn|null $dsn = null ]) : array{sql: string, params: list|array}

未使用のため非推奨

Parameters
$tb : string|null
$w : SQL_Where|null = null
$dsn : Dsn|null = null
Return values
array{sql: string, params: list|array}

dumpSQL()

プレースホルダ付きSQLとparams配列から、デバッグ用のSQLを生成する

public static dumpSQL(array{sql: string, params: list|array$query) : string
Parameters
$query : array{sql: string, params: list|array}
Return values
string

get()

SQL文とパラメータを取得するメソッドです。

public get([mixed $dsn = null ]) : array{sql: string, params: list|array}
Parameters
$dsn : mixed = null
Tags
inheritDoc
Return values
array{sql: string, params: list|array}

getParams()

SQL文のパラメータを取得するメソッドです。

public getParams([Dsn|null $dsn = null ]) : array<string, mixed>
Parameters
$dsn : Dsn|null = null
Return values
array<string, mixed>

getSQL()

SQL文を取得するメソッドです。

public getSQL([Dsn|null $dsn = null ]) : string
Parameters
$dsn : Dsn|null = null
Return values
string

hasData()

データがセットされているかどうかを確認します

public hasData() : bool
Return values
bool

isClass()

第一引数の値が特定の クラス のオブジェクトのインスタンスであるかどうかを判定

public static isClass(mixed $obj, T> $className) : bool
Parameters
$obj : mixed
$className : T>
Tags
template
phpstan-assert-if-true

T $obj

Return values
bool

newBulkInsert()

TABLEを指定してINSERT句(バルク)を生成する為のSQL_BulkInsertを返す

public static newBulkInsert([string|null $tb = null ]) : SQL_BulkInsert
Parameters
$tb : string|null = null
Tags
static
Return values
SQL_BulkInsert

newCase()

CASE文を作成するためのSQL_Field_Caseオブジェクトを生成する <br /> $case = SQL::newCase();<br> $case->add(SQL::newOpr('entry_status', 'draft' '='), '下書き');<br> $case->add(SQL::newOpr('entry_status', 'open' '='), '公開');<br> $case->add(SQL::newOpr('entry_status', 'close' '='), '非公開');<br> $case->setElse('下書き');<br> CASE<br> WHEN entry_status = 'draft' THEN '下書き'<br> WHEN entry_status = 'open' THEN '公開'<br> WHEN entry_status = 'close' THEN '非公開'<br> ELSE '下書き'

public static newCase([SQL|string|null $simple = null ]) : SQL_Field_Case
Parameters
$simple : SQL|string|null = null

単純CASE文を作成する場合はSQLオブジェクトまたは文字列を指定する

Return values
SQL_Field_Case

newDelete()

TABLEを指定してDELETE句を生成する為のSQL_Deleteを返す

public static newDelete([string|null $tb = null ]) : SQL_Delete
Parameters
$tb : string|null = null
Tags
static
Return values
SQL_Delete

newField()

SQL_Fieldオブジェクトを生成する<br> SQL::newField('entry_title', 'entry')<br> entry.entry_title

public static newField(SQL_Field|string|int $fd[, string|null $scp = null ][, bool $quote = true ]) : SQL_Field
Parameters
$fd : SQL_Field|string|int
$scp : string|null = null
$quote : bool = true
Return values
SQL_Field

newFunction()

関数を生成するためのSQL_Field_Functionオブジェクトを生成する<br> $funcに配列を指定すると、添字0を関数名、添字1以降を関数の引数として渡される<br> SQL::newFunction('entry_title', ['SUBSTR', 0, 10])<br> SUBSTR(entry_title, 0, 10)<br>

public static newFunction(SQL_Field|string|int|null $fd[, array<string|int, mixed>|string|null $func = null ][, string|null $scp = null ][, bool $quote = true ]) : SQL_Field_Function

$funcに文字列を指定すると、その文字列が関数名として渡される
SQL::newFunction('entry_id', 'COUNT')
COUNT(entry_id)

Parameters
$fd : SQL_Field|string|int|null
$func : array<string|int, mixed>|string|null = null
$scp : string|null = null
$quote : bool = true
Return values
SQL_Field_Function

newGeometry()

SQLのGeometry関数を作成するためのSQL_Field_Functionオブジェクトを生成する

public static newGeometry(float|string $lat, float|string $lng[, string|null $scp = null ]) : SQL_Field_Function
Parameters
$lat : float|string
$lng : float|string
$scp : string|null = null
Return values
SQL_Field_Function

newInsert()

TABLEを指定してINSERT句を生成する為のSQL_Insertを返す

public static newInsert([string|null $tb = null ]) : SQL_Insert
Parameters
$tb : string|null = null
Tags
static
Return values
SQL_Insert

newInsertOrUpdate()

TABLEを指定してINSERT ON DUPLICATE KEY UPDATE句を生成する為のSQL_InsertOrUpdateを返す

public static newInsertOrUpdate([string|null $tb = null ][, string|null $als = null ]) : SQL_InsertOrUpdate
Parameters
$tb : string|null = null
$als : string|null = null
Tags
static
Return values
SQL_InsertOrUpdate

newOpr()

演算子を生成するためのSQL_Field_Operatorオブジェクトを生成する<br> SQL::newOpr('entry_id', 1, '>')<br> entry_id > 1

public static newOpr(string|SQL_Field $fd[, SQL_Field|string|int|float|null $val = null ][, string $opr = '=' ][, string|null $scp = null ][, array<string|int, mixed>|string|null $func = null ]) : mixed
Parameters
$fd : string|SQL_Field
$val : SQL_Field|string|int|float|null = null
$opr : string = '='
$scp : string|null = null
$func : array<string|int, mixed>|string|null = null

newOprBw()

BETWEEN演算子を作成するためのSQL_Field_Operator_Betweenオブジェクトを生成する<br> SQL::newOprBw('entry_id', 1, 10)<br> entry_id BETWEEN 1 AND 10

public static newOprBw(string|SQL_Field $fd, T $a, T $b[, string|null $scp = null ][, array<string|int, mixed>|string|null $func = null ]) : SQL_Field_Operator_Between<string|int, T>
Parameters
$fd : string|SQL_Field
$a : T

文字列(日付型の文字列)または数値

$b : T

文字列(日付型の文字列)または数値

$scp : string|null = null
$func : array<string|int, mixed>|string|null = null
Tags
template
Return values
SQL_Field_Operator_Between<string|int, T>

newOprExists()

EXISTS演算子を作成するためのSQL_Field_Operator_Existsオブジェクトを生成する<br> SQL::newOprExists(SQL::newSelect('entry'))<br> EXISTS (SELECT * FROM acms_entry)

public static newOprExists(SQL_Select $val[, string|null $scp = null ]) : SQL_Field_Operator_Exists
Parameters
$val : SQL_Select
$scp : string|null = null
Return values
SQL_Field_Operator_Exists

newOprIn()

IN演算子を作成するためのSQL_Field_Operator_Inオブジェクトを生成する<br> SQL::newOprIn('entry_id', [1, 2, 3, 4, 5])<br> entry_id IN (1, 2, 3, 4, 5)

public static newOprIn(string|SQL_Field $fd, array<string|int, mixed>|SQL_Select $val[, string|null $scp = null ][, array<string|int, mixed>|string|null $func = null ]) : SQL_Field_Operator_In
Parameters
$fd : string|SQL_Field
$val : array<string|int, mixed>|SQL_Select
$scp : string|null = null
$func : array<string|int, mixed>|string|null = null
Return values
SQL_Field_Operator_In

newOprNotExists()

NOT EXISTS演算子を作成するためのSQL_Field_Operator_Existsオブジェクトを生成する <br> SQL::newOprExists(SQL::newSelect('entry'))<br> NOT EXISTS (SELECT * FROM acms_entry)

public static newOprNotExists(SQL_Select $val[, string|null $scp = null ]) : SQL_Field_Operator_Exists
Parameters
$val : SQL_Select
$scp : string|null = null
Return values
SQL_Field_Operator_Exists

newOprNotIn()

NOT IN演算子を作成するためのSQL_Field_Operator_Inオブジェクトを生成する<br> SQL::newOprNotIn('entry_id', [1, 2, 3, 4, 5])<br> entry_id NOT IN (1, 2, 3, 4, 5)

public static newOprNotIn(string|SQL_Field $fd, array<string|int, mixed>|SQL_Select $val[, string|null $scp = null ][, array<string|int, mixed>|string|null $func = null ]) : SQL_Field_Operator_In
Parameters
$fd : string|SQL_Field
$val : array<string|int, mixed>|SQL_Select
$scp : string|null = null
$func : array<string|int, mixed>|string|null = null
Return values
SQL_Field_Operator_In

newReplace()

TABLEを指定してREPLACE句を生成する為のSQL_Replaceを返す

public static newReplace([string|null $tb = null ]) : SQL_Replace
Parameters
$tb : string|null = null
Tags
static
Return values
SQL_Replace

newSelect()

TABLEを指定してSELECT句を生成する為のSQL_Selectを返す

public static newSelect([SQL_Select|SQL_Field|string|null $tb = null ][, string|null $als = null ][, bool $straight_join = false ]) : SQL_Select
Parameters
$tb : SQL_Select|SQL_Field|string|null = null
$als : string|null = null
$straight_join : bool = false
Tags
static
Return values
SQL_Select

newSeq()

SQL_Sequenceオブジェクトを生成する

public static newSeq(string $seq[, "nextval"|"currval"|"setval"|"optimize" $method = 'nextval' ][, int|null $val = null ]) : SQL_Sequence
Parameters
$seq : string

シーケンス名 例: entry_id, blog_id, category_id, user_id

$method : "nextval"|"currval"|"setval"|"optimize" = 'nextval'

メソッド名 例: nextval, currval, setval, optimize

$val : int|null = null
Return values
SQL_Sequence

newUpdate()

TABLEを指定してUPDATE句を生成する為のSQL_Updateを返す

public static newUpdate([string|null $tb = null ]) : SQL_Update
Parameters
$tb : string|null = null
Tags
static
Return values
SQL_Update

newWhere()

WHERE句を生成するためのSQL_Whereオブジェクトを生成する

public static newWhere() : SQL_Where
Return values
SQL_Where

nextval()

指定されたsequence fieldのシーケンス番号を1進めてその値を返す<br> SQL::nextval('entry_id', dsn())<br> UPDATE acms_sequence SET sequence_entry_id = ( LAST_INSERT_ID(sequence_entry_id + 1) )

public static nextval(string|SQL_Sequence $seq[, Dsn|null $dsn = null ][, mixed $plugin = false ]) : array{sql: string, params: list|array}
Parameters
$seq : string|SQL_Sequence
$dsn : Dsn|null = null
$plugin : mixed = false
Tags
static
Return values
array{sql: string, params: list|array}

optimizeSeq()

指定されたsequence fieldのシーケンス番号を最適化する<br> SQL::optimizeSeq('entry_id', dsn())<br> UPDATE acms_sequence SET sequence_entry_id = ( LAST_INSERT_ID(sequence_entry_id + 1) )

public static optimizeSeq(string|SQL_Sequence $seq[, Dsn|null $dsn = null ][, bool $plugin = false ]) : array{sql: string, params: list|array}
Parameters
$seq : string|SQL_Sequence
$dsn : Dsn|null = null
$plugin : bool = false
Tags
static
Return values
array{sql: string, params: list|array}

quoteKey()

SQL文のキーを安全に引用符で囲むメソッドです。

public static quoteKey(string $key) : string
Parameters
$key : string
Return values
string

safePlaceholder()

プレースホルダ名を安全に生成する

public static safePlaceholder(string $keyName[, string|null $suffix = null ]) : string
Parameters
$keyName : string

任意のキー名(例: 'user-id.1')

$suffix : string|null = null

一意性のための接尾語(例: '0')

Return values
string

setColumns()

指定されたカラムをINSERT句にセットする

public setColumns(array<string|int, string> $columns) : bool
Parameters
$columns : array<string|int, string>
Return values
bool

setConnection()

データベース接続を設定するメソッドです。

public static setConnection(Connection $connection) : void
Parameters
$connection : Connection

setTable()

public setTable(string $tb) : void
Parameters
$tb : string

setval()

指定されたsequence fieldを指定された値にセットする<br> SQL::setval('entry_id', 10, dsn())<br> UPDATE acms_sequence SET sequence_entry_id = 10

public static setval(string|SQL_Sequence $seq, int $val[, Dsn|null $dsn = null ][, bool $plugin = false ]) : array{sql: string, params: list|array}
Parameters
$seq : string|SQL_Sequence
$val : int
$dsn : Dsn|null = null
$plugin : bool = false
Tags
static
Return values
array{sql: string, params: list|array}

showTable()

TABLEを指定してSHOW TABLE句を生成する為のSQL_ShowTableを返す

public static showTable([string|null $tb = null ]) : SQL_ShowTable
Parameters
$tb : string|null = null
Return values
SQL_ShowTable

        
On this page

Search results