SQL_Field_Operator_Between
extends SQL_Field_Operator
in package
SQL
Tags
Table of Contents
Properties
- $_a : T
- $_args : array<string|int, mixed>|null
- $_b : T
- $_field : SQL_Field|string|int|null
- $_operator : string|null
- $_scope : string|null
- $_value : SQL|array<string|int, mixed>|string|int|float|null
- $_quote : bool
- $connection : Connection
- $result : mixed
Methods
- __construct() : mixed
- 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文とパラメータを取得するメソッドです。
- getBetween() : array<string|int, T>
- getField() : SQL_Field|string|int|null
- getFunction() : array<string|int, mixed>|null
- getOperator() : string|null
- getParams() : array<string, mixed>
- SQL文のパラメータを取得するメソッドです。
- getQuote() : bool
- getScope() : string|null
- getSQL() : string
- SQL文を取得するメソッドです。
- getValue() : SQL|array<string|int, mixed>|string|int|float|null
- 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
- プレースホルダ名を安全に生成する
- setBetween() : true
- 指定されたa, bからBETWEEN句を生成する。<br> $SQL->setBetween(10, 20);<br> BETWEEN 10 AND 20
- setConnection() : void
- データベース接続を設定するメソッドです。
- setField() : true
- setFunction() : true
- SQL関数を設定する。<br> 引数には、配列 or 文字列を指定する。<br> 配列の場合、最初の要素は関数名、それ以降は引数となる。<br> $sqlFunction->setField('entry_title');<br> $sqlFunction->setFunction(['SUBSTR', 0, 10]);<br> SUBSTR(entry_title, 0, 10)<br>
- setOperator() : true
- setQuote() : void
- setScope() : true
-
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
- setValue() : true
- showTable() : SQL_ShowTable
- TABLEを指定してSHOW TABLE句を生成する為のSQL_ShowTableを返す
- _field() : string|int|false
-
_function()
: array{sql: string, params: list|array
} -
_operator()
: array{sql: string, params: list|array
} - _right() : array{val: array|string|int|float|null, opr: string|null, isPlaceholder?: bool}
Properties
$_a
public
T
$_a
= \null
$_args
public
array<string|int, mixed>|null
$_args
= \null
$_b
public
T
$_b
= \null
$_field
public
SQL_Field|string|int|null
$_field
= \null
$_operator
public
string|null
$_operator
= \null
$_scope
public
string|null
$_scope
= \null
$_value
public
SQL|array<string|int, mixed>|string|int|float|null
$_value
= \null
$_quote
protected
bool
$_quote
= \true
$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
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
Return values
array{sql: string, params: list|arraydelete()
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|arraydumpSQL()
プレースホルダ付きSQLとparams配列から、デバッグ用のSQLを生成する
public
static dumpSQL(array{sql: string, params: list|array} $query) : string
Parameters
-
$query
: array{sql: string, params: list|array
}
Return values
stringget()
SQL文とパラメータを取得するメソッドです。
public
get([mixed $dsn = null ]) : array{sql: string, params: list|array}
Parameters
- $dsn : mixed = null
Tags
Return values
array{sql: string, params: list|arraygetBetween()
public
getBetween() : array<string|int, T>
Return values
array<string|int, T>getField()
public
getField() : SQL_Field|string|int|null
Return values
SQL_Field|string|int|nullgetFunction()
public
getFunction(mixed $func) : array<string|int, mixed>|null
Parameters
- $func : mixed
Return values
array<string|int, mixed>|nullgetOperator()
public
getOperator() : string|null
Return values
string|nullgetParams()
SQL文のパラメータを取得するメソッドです。
public
getParams([Dsn|null $dsn = null ]) : array<string, mixed>
Parameters
- $dsn : Dsn|null = null
Return values
array<string, mixed>getQuote()
public
getQuote() : bool
Return values
boolgetScope()
public
getScope() : string|null
Return values
string|nullgetSQL()
SQL文を取得するメソッドです。
public
getSQL([Dsn|null $dsn = null ]) : string
Parameters
- $dsn : Dsn|null = null
Return values
stringgetValue()
public
getValue() : SQL|array<string|int, mixed>|string|int|float|null
Return values
SQL|array<string|int, mixed>|string|int|float|nullisClass()
第一引数の値が特定の クラス のオブジェクトのインスタンスであるかどうかを判定
public
static isClass(mixed $obj, T> $className) : bool
Parameters
- $obj : mixed
- $className : T>
Tags
Return values
boolnewBulkInsert()
TABLEを指定してINSERT句(バルク)を生成する為のSQL_BulkInsertを返す
public
static newBulkInsert([string|null $tb = null ]) : SQL_BulkInsert
Parameters
- $tb : string|null = null
Tags
Return values
SQL_BulkInsertnewCase()
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_CasenewDelete()
TABLEを指定してDELETE句を生成する為のSQL_Deleteを返す
public
static newDelete([string|null $tb = null ]) : SQL_Delete
Parameters
- $tb : string|null = null
Tags
Return values
SQL_DeletenewField()
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_FieldnewFunction()
関数を生成するための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_FunctionnewGeometry()
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_FunctionnewInsert()
TABLEを指定してINSERT句を生成する為のSQL_Insertを返す
public
static newInsert([string|null $tb = null ]) : SQL_Insert
Parameters
- $tb : string|null = null
Tags
Return values
SQL_InsertnewInsertOrUpdate()
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
Return values
SQL_InsertOrUpdatenewOpr()
演算子を生成するための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
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
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_ExistsnewOprIn()
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_InnewOprNotExists()
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_ExistsnewOprNotIn()
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_InnewReplace()
TABLEを指定してREPLACE句を生成する為のSQL_Replaceを返す
public
static newReplace([string|null $tb = null ]) : SQL_Replace
Parameters
- $tb : string|null = null
Tags
Return values
SQL_ReplacenewSelect()
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
Return values
SQL_SelectnewSeq()
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_SequencenewUpdate()
TABLEを指定してUPDATE句を生成する為のSQL_Updateを返す
public
static newUpdate([string|null $tb = null ]) : SQL_Update
Parameters
- $tb : string|null = null
Tags
Return values
SQL_UpdatenewWhere()
WHERE句を生成するためのSQL_Whereオブジェクトを生成する
public
static newWhere() : SQL_Where
Return values
SQL_Wherenextval()
指定された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
Return values
array{sql: string, params: list|arrayoptimizeSeq()
指定された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
Return values
array{sql: string, params: list|arrayquoteKey()
SQL文のキーを安全に引用符で囲むメソッドです。
public
static quoteKey(string $key) : string
Parameters
- $key : string
Return values
stringsafePlaceholder()
プレースホルダ名を安全に生成する
public
static safePlaceholder(string $keyName[, string|null $suffix = null ]) : string
Parameters
- $keyName : string
-
任意のキー名(例: 'user-id.1')
- $suffix : string|null = null
-
一意性のための接尾語(例: '0')
Return values
stringsetBetween()
指定されたa, bからBETWEEN句を生成する。<br> $SQL->setBetween(10, 20);<br> BETWEEN 10 AND 20
public
setBetween(T $a, T $b) : true
Parameters
- $a : T
- $b : T
Return values
truesetConnection()
データベース接続を設定するメソッドです。
public
static setConnection(Connection $connection) : void
Parameters
- $connection : Connection
setField()
public
setField(SQL_Field|string|int|null $fd) : true
Parameters
- $fd : SQL_Field|string|int|null
Return values
truesetFunction()
SQL関数を設定する。<br> 引数には、配列 or 文字列を指定する。<br> 配列の場合、最初の要素は関数名、それ以降は引数となる。<br> $sqlFunction->setField('entry_title');<br> $sqlFunction->setFunction(['SUBSTR', 0, 10]);<br> SUBSTR(entry_title, 0, 10)<br>
public
setFunction(array<string|int, mixed>|string|int|null $args) : true
文字列の場合、その文字列が関数名として渡される
$sqlFunction->setField('entry_id');
$sqlFunction->setFunction('COUNT');
COUNT(entry_id)
Parameters
- $args : array<string|int, mixed>|string|int|null
Return values
truesetOperator()
public
setOperator(string $opr) : true
Parameters
- $opr : string
Return values
truesetQuote()
public
setQuote(bool $quote) : void
Parameters
- $quote : bool
setScope()
public
setScope(string|null $scp) : true
Parameters
- $scp : string|null
Return values
truesetval()
指定された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
Return values
array{sql: string, params: list|arraysetValue()
public
setValue(SQL|array<string|int, mixed>|string|int|float|null $val) : true
Parameters
- $val : SQL|array<string|int, mixed>|string|int|float|null
Return values
trueshowTable()
TABLEを指定してSHOW TABLE句を生成する為のSQL_ShowTableを返す
public
static showTable([string|null $tb = null ]) : SQL_ShowTable
Parameters
- $tb : string|null = null
Return values
SQL_ShowTable_field()
protected
_field([Dsn|null $dsn = null ]) : string|int|false
Parameters
- $dsn : Dsn|null = null
Return values
string|int|false_function()
protected
_function([Dsn|null $dsn = null ]) : array{sql: string, params: list|array}
Parameters
- $dsn : Dsn|null = null
Return values
array{sql: string, params: list|array_operator()
protected
_operator([mixed $dsn = null ]) : array{sql: string, params: list|array}
Parameters
- $dsn : mixed = null
Tags
Return values
array{sql: string, params: list|array_right()
protected
_right([Dsn|null $dsn = null ]) : array{val: array|string|int|float|null, opr: string|null, isPlaceholder?: bool}
Parameters
- $dsn : Dsn|null = null