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