Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SendFriend.php
Go to the documentation of this file.
1 <?php
7 
17 {
23  protected function _construct()
24  {
25  $this->_init('sendfriend_log', 'log_id');
26  }
27 
38  public function getSendCount($object, $ip, $startTime, $websiteId = null)
39  {
40  $connection = $this->getConnection();
41  $select = $connection->select()->from(
42  $this->getMainTable(),
43  ['count' => new \Zend_Db_Expr('count(*)')]
44  )->where(
45  'ip=:ip
46  AND time>=:time
47  AND website_id=:website_id'
48  );
49  $bind = ['ip' => $ip, 'time' => $startTime, 'website_id' => (int)$websiteId];
50 
51  $row = $connection->fetchRow($select, $bind);
52  return $row['count'];
53  }
54 
63  public function addSendItem($ip, $startTime, $websiteId)
64  {
65  $this->getConnection()->insert(
66  $this->getMainTable(),
67  ['ip' => $ip, 'time' => $startTime, 'website_id' => $websiteId]
68  );
69  return $this;
70  }
71 
78  public function deleteLogsBefore($time)
79  {
80  $cond = $this->getConnection()->quoteInto('time<?', $time);
81  $this->getConnection()->delete($this->getMainTable(), $cond);
82 
83  return $this;
84  }
85 }
$connection
Definition: bulk.php:13
getSendCount($object, $ip, $startTime, $websiteId=null)
Definition: SendFriend.php:38
addSendItem($ip, $startTime, $websiteId)
Definition: SendFriend.php:63