PHP 클래스 StatementBuilder, googleads-php-lib

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();
파일 보기 프로젝트 열기: googleads/googleads-php-lib 1 사용 예제들

공개 메소드들

메소드 설명
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.

메소드 상세

From() 공개 메소드

Only necessary for statements being sent to the {@code PublisherQueryLanguageService}. The "FROM " keyword will be ignored.
public From ( string $table ) : StatementBuilder
$table string the statement from clause without "FROM"
리턴 StatementBuilder a reference to this object

GetBindVariableMap() 공개 메소드

Returns the key to value map.
public GetBindVariableMap ( )

GetOffset() 공개 메소드

Gets the current offset.
public GetOffset ( ) : integer
리턴 integer the current offset

IncreaseOffsetBy() 공개 메소드

Increases the offset by the {@code amount}.
public IncreaseOffsetBy ( integer $amount ) : StatementBuilder
$amount integer the amount to increase the offset
리턴 StatementBuilder a reference to this object

Limit() 공개 메소드

Sets the statement LIMIT clause in the form of

"LIMIT <count>"

e.g. 1000.
public Limit ( integer $count ) : StatementBuilder
$count integer the statement limit
리턴 StatementBuilder a reference to this object

Offset() 공개 메소드

Sets the statement OFFSET clause in the form of

"OFFSET <count>"

e.g. 200.
public Offset ( integer $count ) : StatementBuilder
$count integer the statement offset
리턴 StatementBuilder a reference to this object

OrderBy() 공개 메소드

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.
public OrderBy ( string $orderBy ) : StatementBuilder
$orderBy string the statement order by without "ORDER BY"
리턴 StatementBuilder a reference to this object

RemoveLimitAndOffset() 공개 메소드

Removes the limit and offset from the query.
public RemoveLimitAndOffset ( ) : StatementBuilder
리턴 StatementBuilder a reference to this object

Select() 공개 메소드

Only necessary for statements being sent to the {@code PublisherQueryLanguageService}. The "SELECT " keyword will be ignored.
public Select ( string $columns ) : StatementBuilder
$columns string the statement select clause without "SELECT"
리턴 StatementBuilder a reference to this object

ToStatement() 공개 메소드

Gets the {@link Statement} representing the state of this statement builder.
public ToStatement ( ) : Statement
리턴 Statement the {@link Statement}

Where() 공개 메소드

..}"

e.g. "a = b OR b = c". The "WHERE " keyword will be ignored.
public Where ( string $conditions ) : StatementBuilder
$conditions string the statement query without "WHERE"
리턴 StatementBuilder a reference to this object

WithBindVariableValue() 공개 메소드

Adds a value to the statement in the form of a {@code Value}.
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

__construct() 공개 메소드

Constructs a new instance of this statement builder.
public __construct ( )