Entity.php 1020 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Review\Model\ResourceModel\Rating;
  7. /**
  8. * Rating entity resource
  9. *
  10. * @author Magento Core Team <core@magentocommerce.com>
  11. */
  12. class Entity extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
  13. {
  14. /**
  15. * Rating entity resource initialization
  16. *
  17. * @return void
  18. */
  19. protected function _construct()
  20. {
  21. $this->_init('rating_entity', 'entity_id');
  22. }
  23. /**
  24. * Return entity_id by entityCode
  25. *
  26. * @param string $entityCode
  27. * @return int
  28. */
  29. public function getIdByCode($entityCode)
  30. {
  31. $connection = $this->getConnection();
  32. $select = $connection->select()->from(
  33. $this->getTable('rating_entity'),
  34. $this->getIdFieldName()
  35. )->where(
  36. 'entity_code = :entity_code'
  37. );
  38. return $connection->fetchOne($select, [':entity_code' => $entityCode]);
  39. }
  40. }