History.php 963 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\ImportExport\Model\ResourceModel;
  7. /**
  8. * Class History
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class History extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
  14. {
  15. /**
  16. * Define main table
  17. *
  18. * @return void
  19. */
  20. protected function _construct()
  21. {
  22. $this->_init('import_history', 'history_id');
  23. }
  24. /**
  25. * Retrieve last inserted report id by user id
  26. *
  27. * @param string $userId
  28. * @return int $lastId
  29. */
  30. public function getLastInsertedId($userId)
  31. {
  32. $connection = $this->getConnection();
  33. $select = $connection
  34. ->select()
  35. ->from($this->getMainTable())
  36. ->order($this->getIdFieldName() . ' DESC')
  37. ->where('user_id = ?', $userId)
  38. ->limit(1);
  39. return $connection->fetchOne($select);
  40. }
  41. }