Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Helper.php
Go to the documentation of this file.
1 <?php
7 
15 {
19  const DB_MAX_PACKET_SIZE = 1048576;
20 
21  // Maximal packet length by default in MySQL
23 
24  // The coefficient of useful data from maximum packet length
25 
30  public function __construct(\Magento\Framework\App\ResourceConnection $resource, $modulePrefix = 'importexport')
31  {
32  parent::__construct($resource, $modulePrefix);
33  }
34 
40  public function getMaxDataSize()
41  {
42  $maxPacketData = $this->getConnection()->fetchRow('SHOW VARIABLES LIKE "max_allowed_packet"');
43  $maxPacket = empty($maxPacketData['Value']) ? self::DB_MAX_PACKET_SIZE : $maxPacketData['Value'];
44  return floor($maxPacket * self::DB_MAX_PACKET_COEFFICIENT);
45  }
46 
54  {
55  $connection = $this->getConnection();
56  $entityStatus = $connection->showTableStatus($tableName);
57 
58  if (empty($entityStatus['Auto_increment'])) {
59  throw new \Magento\Framework\Exception\LocalizedException(__('Cannot get autoincrement value'));
60  }
61  return $entityStatus['Auto_increment'];
62  }
63 }
$tableName
Definition: trigger.php:13
__()
Definition: __.php:13
$resource
Definition: bulk.php:12
__construct(\Magento\Framework\App\ResourceConnection $resource, $modulePrefix='importexport')
Definition: Helper.php:30
$connection
Definition: bulk.php:13