Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractGrid.php
Go to the documentation of this file.
1 <?php
7 
10 
16 abstract class AbstractGrid extends AbstractDb implements GridInterface
17 {
21  protected $connection;
22 
26  protected $gridTableName;
27 
31  protected $orderTableName = 'sales_order';
32 
36  protected $addressTableName = 'sales_order_address';
37 
43  protected function _construct()
44  {
45  //
46  }
47 
53  public function getConnection()
54  {
55  if (!$this->connection) {
56  $this->connection = $this->_resources->getConnection('sales');
57  }
58  return $this->connection;
59  }
60 
66  public function getGridTable()
67  {
68  return $this->getTable($this->gridTableName);
69  }
70 
78  public function purge($value, $field = null)
79  {
80  return $this->getConnection()->delete(
81  $this->getTable($this->gridTableName),
82  [($field ?: 'entity_id') . ' = ?' => $value]
83  );
84  }
85 
97  protected function getLastUpdatedAtValue($default = '0000-00-00 00:00:00')
98  {
99  $select = $this->getConnection()->select()
100  ->from($this->getTable($this->gridTableName), ['updated_at'])
101  ->order('updated_at DESC')
102  ->limit(1);
103 
104  $row = $this->getConnection()->fetchRow($select);
105 
106  return isset($row['updated_at']) ? $row['updated_at'] : $default;
107  }
108 }
$value
Definition: gender.phtml:16
getLastUpdatedAtValue($default='0000-00-00 00:00:00')