Open Journal Systems  2.4.3
 All Classes Namespaces Functions Variables Groups Pages
UsageStatsTemporaryRecordDAO.inc.php
1 <?php
2 
18 
20  var $_result;
21 
23  var $_loadId;
24 
29  parent::DAO();
30 
31  $this->_result = false;
32  $this->_loadId = null;
33  }
34 
47  function insert($assocType, $assocId, $day, $countryCode, $region, $cityName, $fileType, $loadId) {
48  $this->update(
49  'INSERT INTO usage_stats_temporary_records
50  (assoc_type, assoc_id, day, country_id, region, city, file_type, load_id)
51  VALUES
52  (?, ?, ?, ?, ?, ?, ?, ?)',
53  array(
54  (int) $assocType,
55  (int) $assocId,
56  $day,
57  $countryCode,
58  (int) $region,
59  $cityName,
60  (int) $fileType,
61  $loadId // Not number.
62  )
63  );
64 
65  return true;
66  }
67 
74  function &getNextByLoadId($loadId) {
75  $returner = false;
76 
77  if (!$this->_result || $this->_loadId != $loadId) {
78  $this->_result =& $this->_getGrouped($loadId);
79  $this->_loadId = $loadId;
80  }
81 
82  $result =& $this->_result;
83 
84  if ($result->EOF) return $returner;
85  $returner =& $result->GetRowAssoc(false);
86  $result->MoveNext();
87  return $returner;
88  }
89 
96  function deleteByLoadId($loadId) {
97  return $this->update('DELETE from usage_stats_temporary_records WHERE load_id = ?', array($loadId)); // Not number.
98  }
99 
108  function deleteRecord($assocType, $assocId, $loadId) {
109  return $this->update('DELETE from usage_stats_temporary_records
110  WHERE assoc_type = ? AND assoc_id = ? AND load_id = ?
111  ORDER BY day DESC
112  LIMIT 1',
113  array((int) $assocType, (int) $assocId, $loadId)); // Not number.
114  }
115 
116 
117  //
118  // Private helper methods.
119  //
125  function &_getGrouped($loadId) {
126  $result = $this->retrieve(
127  'SELECT assoc_type, assoc_id, day, country_id, region, city, file_type, load_id, count(metric) as metric
128  FROM usage_stats_temporary_records WHERE load_id = ?
129  GROUP BY assoc_type, assoc_id, day, country_id, region, city, file_type, load_id',
130  array($loadId) // Not number.
131  );
132 
133  return $result;
134  }
135 }
136 
137 ?>
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:29
Operations for retrieving and adding temporary usage statistics records.
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:83
deleteRecord($assocType, $assocId, $loadId)
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:211
insert($assocType, $assocId, $day, $countryCode, $region, $cityName, $fileType, $loadId)