Typical usage is:
$statementBuilder = new StatementBuilder() ->Where("lastModifiedDateTime > :yesterday AND type = :type") ->OrderBy("name DESC") ->Limit(200) ->Offset(20) ->WithBindVariableValue("yesterday", date(DateTimeUtils::$DFP_DATE_TIME_STRING_FORMAT, strtotime('-1 day')) ->WithBindVariableValue("type", "Type") $statement = $statementBuilder->ToStatement(); ... $statementBuilder->IncreaseOffsetBy(20); $statement = $statementBuilder->ToStatement();Показать файл Открыть проект Примеры использования класса
Метод | Описание | |
---|---|---|
From ( string $table ) : StatementBuilder | Sets the statement FROM clause in the form of "table". | |
GetBindVariableMap ( ) | Returns the key to value map. | |
GetOffset ( ) : integer | Gets the current offset. | |
IncreaseOffsetBy ( integer $amount ) : StatementBuilder | Increases the offset by the {@code amount}. | |
Limit ( integer $count ) : StatementBuilder |
Sets the statement LIMIT clause in the form of"LIMIT <count>"
e.g. 1000. |
|
Offset ( integer $count ) : StatementBuilder |
Sets the statement OFFSET clause in the form of"OFFSET <count>"
e.g. 200. |
|
OrderBy ( string $orderBy ) : StatementBuilder |
Sets the statement ORDER BY clause in the form of"ORDER BY <property> [ASC | DESC]"
e.g. "type ASC, lastModifiedDateTime DESC". The "ORDER BY " keyword will be ignored. |
|
RemoveLimitAndOffset ( ) : StatementBuilder | Removes the limit and offset from the query. | |
Select ( string $columns ) : StatementBuilder | Sets the statement SELECT clause in the form of "a,b" or "*". | |
ToStatement ( ) : Statement | Gets the {@link Statement} representing the state of this statement builder. | |
Where ( string $conditions ) : StatementBuilder |
Sets the statement WHERE clause in the form of"WHERE <condition> {[AND | OR] <condition> . |
|
WithBindVariableValue ( string $key, mixed $value ) : StatementBuilder | Adds a value to the statement in the form of a {@code Value}. | |
__construct ( ) | Constructs a new instance of this statement builder. |
Метод | Описание | |
---|---|---|
buildQuery ( ) : string | Builds the query from the clauses. | |
removeKeyword ( string $clause, string $keyword ) : string | Removes the {@code keyword} from the {@code clause} if present. Will remove {@code keyword + " "}. | |
validateQuery ( ) | Checks that the query is valid. |
public IncreaseOffsetBy ( integer $amount ) : StatementBuilder | ||
$amount | integer | the amount to increase the offset |
Результат | StatementBuilder | a reference to this object |
"LIMIT <count>"
"OFFSET <count>"
"ORDER BY <property> [ASC | DESC]"
public RemoveLimitAndOffset ( ) : StatementBuilder | ||
Результат | StatementBuilder | a reference to this object |
public ToStatement ( ) : Statement | ||
Результат | Statement | the {@link Statement} |
public WithBindVariableValue ( string $key, mixed $value ) : StatementBuilder | ||
$key | string | the value key |
$value | mixed | the value either as a primitive, which will be converted to a PQL Value object, or a PQL Value object |
Результат | StatementBuilder | a reference to this object |
public __construct ( ) |