diff options
author | diosmosis <benaka@piwik.pro> | 2015-03-11 14:44:44 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-03-11 14:44:44 +0300 |
commit | e477518993e1c59dc36f0c05d22dcf85942d4e07 (patch) | |
tree | 7a97e96fcbcdd1d81f4de1e4f1431141d11dc510 /core | |
parent | a1388b84ba44fb67b21b735ffe3b38060c0e94f9 (diff) |
Merge RawLogFetcher and RawLogUpdater to RawLogDao.
Diffstat (limited to 'core')
-rw-r--r-- | core/DataAccess/RawLogDao.php (renamed from core/DataAccess/RawLogUpdater.php) | 50 | ||||
-rw-r--r-- | core/DataAccess/RawLogFetcher.php | 55 |
2 files changed, 45 insertions, 60 deletions
diff --git a/core/DataAccess/RawLogUpdater.php b/core/DataAccess/RawLogDao.php index a19ce52e94..28f2a07978 100644 --- a/core/DataAccess/RawLogUpdater.php +++ b/core/DataAccess/RawLogDao.php @@ -11,7 +11,10 @@ namespace Piwik\DataAccess; use Piwik\Common; use Piwik\Db; -class RawLogUpdater +/** + * DAO that queries log tables. + */ +class RawLogDao { /** * @param array $values @@ -20,8 +23,8 @@ class RawLogUpdater public function updateVisits(array $values, $idVisit) { $sql = "UPDATE " . Common::prefixTable('log_visit') - . " SET " . $this->getColumnSetExpressions(array_keys($values)) - . " WHERE idvisit = ?"; + . " SET " . $this->getColumnSetExpressions(array_keys($values)) + . " WHERE idvisit = ?"; $this->update($sql, $values, $idVisit); } @@ -33,13 +36,50 @@ class RawLogUpdater public function updateConversions(array $values, $idVisit) { $sql = "UPDATE " . Common::prefixTable('log_conversion') - . " SET " . $this->getColumnSetExpressions(array_keys($values)) - . " WHERE idvisit = ?"; + . " SET " . $this->getColumnSetExpressions(array_keys($values)) + . " WHERE idvisit = ?"; $this->update($sql, $values, $idVisit); } /** + * @param string $from + * @param string $to + * @param array $fields + * @param int $fromId + * @param int $limit + * @return array[] + */ + public function getVisitsWithDatesLimit($from, $to, $fields = array(), $fromId = 0, $limit = 1000) + { + $sql = "SELECT " . implode(', ', $fields) + . " FROM " . Common::prefixTable('log_visit') + . " WHERE visit_first_action_time >= ? AND visit_last_action_time < ?" + . " AND idvisit > ?" + . sprintf(" LIMIT %d", $limit); + + $bind = array($from, $to, $fromId); + + return Db::fetchAll($sql, $bind); + } + + /** + * @param string $from + * @param string $to + * @return int + */ + public function countVisitsWithDatesLimit($from, $to) + { + $sql = "SELECT COUNT(*) AS num_rows" + . " FROM " . Common::prefixTable('log_visit') + . " WHERE visit_first_action_time >= ? AND visit_last_action_time < ?"; + + $bind = array($from, $to); + + return (int) Db::fetchOne($sql, $bind); + } + + /** * @param array $columnsToSet * @return string */ diff --git a/core/DataAccess/RawLogFetcher.php b/core/DataAccess/RawLogFetcher.php deleted file mode 100644 index 0a867e24a3..0000000000 --- a/core/DataAccess/RawLogFetcher.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php -/** - * Piwik - free/libre analytics platform - * - * @link http://piwik.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - * - */ -namespace Piwik\DataAccess; - -use Piwik\Common; -use Piwik\Db; - -/** - * DAO that queries log tables. - */ -class RawLogFetcher -{ - /** - * @param string $from - * @param string $to - * @param array $fields - * @param int $fromId - * @param int $limit - * @return array[] - */ - public function getVisitsWithDatesLimit($from, $to, $fields = array(), $fromId = 0, $limit = 1000) - { - $sql = "SELECT " . implode(', ', $fields) - . " FROM " . Common::prefixTable('log_visit') - . " WHERE visit_first_action_time >= ? AND visit_last_action_time < ?" - . " AND idvisit > ?" - . sprintf(" LIMIT %d", $limit); - - $bind = array($from, $to, $fromId); - - return Db::fetchAll($sql, $bind); - } - - /** - * @param string $from - * @param string $to - * @return int - */ - public function countVisitsWithDatesLimit($from, $to) - { - $sql = "SELECT COUNT(*) AS num_rows" - . " FROM " . Common::prefixTable('log_visit') - . " WHERE visit_first_action_time >= ? AND visit_last_action_time < ?"; - - $bind = array($from, $to); - - return (int) Db::fetchOne($sql, $bind); - } -}
\ No newline at end of file |