ExistsConditionBuilder.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\db\conditions;
  8. use yii\db\ExpressionBuilderInterface;
  9. use yii\db\ExpressionBuilderTrait;
  10. use yii\db\ExpressionInterface;
  11. /**
  12. * Class ExistsConditionBuilder builds objects of [[ExistsCondition]]
  13. *
  14. * @author Dmytro Naumenko <d.naumenko.a@gmail.com>
  15. * @since 2.0.14
  16. */
  17. class ExistsConditionBuilder implements ExpressionBuilderInterface
  18. {
  19. use ExpressionBuilderTrait;
  20. /**
  21. * Method builds the raw SQL from the $expression that will not be additionally
  22. * escaped or quoted.
  23. *
  24. * @param ExpressionInterface|ExistsCondition $expression the expression to be built.
  25. * @param array $params the binding parameters.
  26. * @return string the raw SQL that will not be additionally escaped or quoted.
  27. */
  28. public function build(ExpressionInterface $expression, array &$params = [])
  29. {
  30. $operator = $expression->getOperator();
  31. $query = $expression->getQuery();
  32. $sql = $this->queryBuilder->buildExpression($query, $params);
  33. return "$operator $sql";
  34. }
  35. }