MapperInterface.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\DB;
  7. /**
  8. * Interface MapperInterface
  9. */
  10. interface MapperInterface
  11. {
  12. const SORT_ORDER_ASC = 'ASC';
  13. const SORT_ORDER_DESC = 'DESC';
  14. /**
  15. * Map criteria to Select Query Object
  16. *
  17. * @param \Magento\Framework\Api\CriteriaInterface $criteria
  18. * @return Select
  19. */
  20. public function map(\Magento\Framework\Api\CriteriaInterface $criteria);
  21. /**
  22. * Get resource instance
  23. *
  24. * @return \Magento\Framework\Model\ResourceModel\Db\AbstractDb
  25. */
  26. public function getResource();
  27. /**
  28. * Add attribute expression (SUM, COUNT, etc)
  29. * Example: ('sub_total', 'SUM({{attribute}})', 'revenue')
  30. * Example: ('sub_total', 'SUM({{revenue}})', 'revenue')
  31. * For some functions like SUM use groupByAttribute.
  32. *
  33. * @param string $alias
  34. * @param string $expression
  35. * @param array|string $fields
  36. * @return $this
  37. */
  38. public function addExpressionFieldToSelect($alias, $expression, $fields);
  39. /**
  40. * Add field filter to collection
  41. *
  42. * If $condition integer or string - exact value will be filtered ('eq' condition)
  43. *
  44. * If $condition is array - one of the following structures is expected:
  45. * <pre>
  46. * - ["from" => $fromValue, "to" => $toValue]
  47. * - ["eq" => $equalValue]
  48. * - ["neq" => $notEqualValue]
  49. * - ["like" => $likeValue]
  50. * - ["in" => [$inValues]]
  51. * - ["nin" => [$notInValues]]
  52. * - ["notnull" => $valueIsNotNull]
  53. * - ["null" => $valueIsNull]
  54. * - ["moreq" => $moreOrEqualValue]
  55. * - ["gt" => $greaterValue]
  56. * - ["lt" => $lessValue]
  57. * - ["gteq" => $greaterOrEqualValue]
  58. * - ["lteq" => $lessOrEqualValue]
  59. * - ["finset" => $valueInSet]
  60. * </pre>
  61. *
  62. * If non matched - sequential parallel arrays are expected and OR conditions
  63. * will be built using above mentioned structure.
  64. *
  65. * Example:
  66. * <pre>
  67. * $field = ['age', 'name'];
  68. * $condition = [42, ['like' => 'Mage']];
  69. * </pre>
  70. * The above would find where age equal to 42 OR name like %Mage%.
  71. *
  72. * @param string|array $field
  73. * @param string|int|array $condition
  74. * @throws \Magento\Framework\Exception\LocalizedException if some error in the input could be detected.
  75. * @return void
  76. */
  77. public function addFieldToFilter($field, $condition = null);
  78. /**
  79. * Reset Select object state
  80. *
  81. * @return void
  82. */
  83. public function reset();
  84. }