InQueryModifier.php 719 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\DB\Select;
  7. use Magento\Framework\DB\Select;
  8. /**
  9. * Add IN condition to select
  10. */
  11. class InQueryModifier implements QueryModifierInterface
  12. {
  13. /**
  14. * @var array
  15. */
  16. private $values;
  17. /**
  18. * Constructor
  19. *
  20. * @param array $values
  21. */
  22. public function __construct(
  23. $values = []
  24. ) {
  25. $this->values = $values;
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function modify(Select $select)
  31. {
  32. foreach ($this->values as $field => $values) {
  33. $select->where($field . ' IN (?)', $values);
  34. }
  35. }
  36. }