12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace yii\db\conditions;
- use yii\db\ExpressionBuilderInterface;
- use yii\db\ExpressionBuilderTrait;
- use yii\db\ExpressionInterface;
- class BetweenConditionBuilder implements ExpressionBuilderInterface
- {
- use ExpressionBuilderTrait;
-
- public function build(ExpressionInterface $expression, array &$params = [])
- {
- $operator = $expression->getOperator();
- $column = $expression->getColumn();
- if (strpos($column, '(') === false) {
- $column = $this->queryBuilder->db->quoteColumnName($column);
- }
- $phName1 = $this->createPlaceholder($expression->getIntervalStart(), $params);
- $phName2 = $this->createPlaceholder($expression->getIntervalEnd(), $params);
- return "$column $operator $phName1 AND $phName2";
- }
-
- protected function createPlaceholder($value, &$params)
- {
- if ($value instanceof ExpressionInterface) {
- return $this->queryBuilder->buildExpression($value, $params);
- }
- return $this->queryBuilder->bindParam($value, $params);
- }
- }
|