LikeConditionBuilder.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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\oci\conditions;
  8. use yii\db\ExpressionInterface;
  9. /**
  10. * {@inheritdoc}
  11. */
  12. class LikeConditionBuilder extends \yii\db\conditions\LikeConditionBuilder
  13. {
  14. /**
  15. * {@inheritdoc}
  16. */
  17. protected $escapeCharacter = '!';
  18. /**
  19. * `\` is initialized in [[buildLikeCondition()]] method since
  20. * we need to choose replacement value based on [[\yii\db\Schema::quoteValue()]].
  21. * {@inheritdoc}
  22. */
  23. protected $escapingReplacements = [
  24. '%' => '!%',
  25. '_' => '!_',
  26. '!' => '!!',
  27. ];
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function build(ExpressionInterface $expression, array &$params = [])
  32. {
  33. if (!isset($this->escapingReplacements['\\'])) {
  34. /*
  35. * Different pdo_oci8 versions may or may not implement PDO::quote(), so
  36. * yii\db\Schema::quoteValue() may or may not quote \.
  37. */
  38. $this->escapingReplacements['\\'] = substr($this->queryBuilder->db->quoteValue('\\'), 1, -1);
  39. }
  40. return parent::build($expression, $params);
  41. }
  42. }