本文整理汇总了PHP中Condition::setFirstParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP Condition::setFirstParameter方法的具体用法?PHP Condition::setFirstParameter怎么用?PHP Condition::setFirstParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Condition
的用法示例。
在下文中一共展示了Condition::setFirstParameter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convertSqlToJob
public function convertSqlToJob(SQLTokenIterator $tokens, $from = TokenIterator::NEXT)
{
if (!$tokens->seekTokenText('(', $from)) {
throw new ErrorException("Tried to parse sql-parenthesis when token-iterator does not point to paranthesis ('(' sign)!");
}
/* @var $parenthesis ParenthesisPart */
$parenthesis = new ParenthesisPart();
switch (true) {
case $this->selectParser->canParseTokens($tokens):
$parenthesis->setContain($this->selectParser->convertSqlToJob($tokens));
break;
case $this->valueParser->canParseTokens($tokens):
$parenthesis->setContain($this->valueParser->convertSqlToJob($tokens));
break;
}
if (!$tokens->seekTokenText(')')) {
throw new MalformedSqlException("Missing ')' at the end of a parenthesis!", $tokens);
}
if ($tokens->seekTokenNum(T_STRING, TokenIterator::NEXT, [SqlToken::T_AS()])) {
$parenthesis->setAlias($tokens->getCurrentTokenString());
}
if ($parenthesis->getContain() instanceof Select && $tokens->isTokenNum(SqlToken::T_UNION())) {
$unionSelect = new Select();
while ($tokens->seekTokenNum(SqlToken::T_UNION())) {
/* @var $lastUnionedSelect Select */
$lastUnionedSelect = $parenthesis->getContain();
while (!is_null($lastUnionedSelect->getUnionSelect())) {
$lastUnionedSelect = $lastUnionedSelect->getUnionSelect();
}
$isUnionAll = $tokens->seekTokenNum(SqlToken::T_ALL());
$isUnionDistinct = $tokens->seekTokenNum(SqlToken::T_DISTINCT());
$isUnionAll = $isUnionAll || $tokens->seekTokenNum(SqlToken::T_ALL());
if ($isUnionAll && $isUnionDistinct) {
throw new MalformedSqlException("UNION cannot be ALL and DISTINCT at the same time!", $tokens);
}
$isUnionInParenthesis = $tokens->seekTokenText('(');
if (!$this->selectParser->canParseTokens($tokens)) {
throw new MalformedSqlException("Missing following SELECT statement after UNION in SELECT statement!", $tokens);
}
$lastUnionedSelect->setUnionSelect($this->selectParser->convertSqlToJob($tokens), $isUnionDistinct);
if ($isUnionInParenthesis && !$tokens->seekTokenText(')')) {
throw new MalformedSqlException("Missing ending parenthesis after UNION in SELECT statement!", $tokens);
}
}
$unionSelect->setUnionSelect($parenthesis->getContain());
### APPENDED CONDITION (HAVING)
if ($tokens->seekTokenNum(SqlToken::T_HAVING())) {
if (!$this->valueParser->canParseTokens($tokens)) {
throw new MalformedSqlException("Missing condition for WHERE clause in SELECT statement!", $tokens);
}
$condition = new Condition();
$condition->setFirstParameter($this->valueParser->convertSqlToJob($tokens));
$unionSelect->setResultFilter($condition);
}
### ORDER
if ($tokens->seekTokenNum(SqlToken::T_ORDER())) {
if (!$tokens->seekTokenNum(SqlToken::T_BY())) {
throw new MalformedSqlException("Missing BY after ORDER on SELECT statement!", $tokens);
}
do {
if (!$this->valueParser->canParseTokens($tokens)) {
throw new MalformedSqlException("Missing value for ORDER BY part on SELECT statement!", $tokens);
}
$orderValue = $this->valueParser->convertSqlToJob($tokens);
if ($tokens->seekTokenNum(SqlToken::T_DESC())) {
$unionSelect->addOrderColumn($orderValue, SqlToken::T_DESC());
} else {
$tokens->seekTokenNum(SqlToken::T_ASC());
$unionSelect->addOrderColumn($orderValue, SqlToken::T_ASC());
}
} while ($tokens->seekTokenText(','));
}
### LIMIT
if ($tokens->seekTokenNum(SqlToken::T_LIMIT())) {
if (!$tokens->seekTokenNum(T_NUM_STRING)) {
throw new MalformedSqlException("Missing offset number for LIMIT part in SELECT statement!", $tokens);
}
$unionSelect->setLimitOffset((int) $tokens->getCurrentTokenString());
if ($tokens->seekTokenText(',')) {
if (!$tokens->seekTokenNum(T_NUM_STRING)) {
throw new MalformedSqlException("Missing length number for LIMIT part in SELECT statement!", $tokens);
}
$unionSelect->setLimitRowCount((int) $tokens->getCurrentTokenString());
}
}
$parenthesis->setContain($unionSelect);
}
return $parenthesis;
}