forked from matomo-org/matomo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogTable.php
122 lines (112 loc) · 4.34 KB
/
LogTable.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Tracker;
/**
* Base class for LogTables. You need to create a log table eg if you want to be able to create a segment for a custom
* log table.
*/
abstract class LogTable {
/**
* Get the unprefixed database table name. For example 'log_visit' or 'log_action'.
* @return string
*/
abstract public function getName();
/**
* Get the name of the column that represents the primary key. For example "idvisit" or "idlink_va". If the table
* does not have a unique ID for each row, you may choose a column that comes closest to it, for example "idvisit".
* @return string
*/
public function getIdColumn()
{
return '';
}
/**
* Get the name of the column that can be used to join a visit with another table. This is the name of the column
* that represents the "idvisit".
* @return string
*/
public function getColumnToJoinOnIdVisit()
{
return '';
}
/**
* Get the name of the column that can be used to join an action with another table. This is the name of the column
* that represents the "idaction".
*
* This could be more generic eg by specifying "$this->joinableOn = array('action' => 'idaction') and this
* would allow to also add more complex structures in the future but not needed for now I'd say. Let's go with
* simpler, more clean and expressive solution for now until needed.
*
* @return string
*/
public function getColumnToJoinOnIdAction()
{
return '';
}
/**
* If a table can neither be joined via idVisit nor idAction, it should be given a way to join with other tables
* so the log table can be joined via idvisit through a different table joins.
*
* For this to work it requires the same column to be present in two tables. If for example you have a table
* `log_foo_bar (idlogfoobar, idlogfoo)` and a table `log_foo(idlogfoo, idsite, idvisit)`, then you can in the
* log table instance for `log_foo_bar` return `array('log_foo' => 'idlogfoo')`. This tells the core that a join
* with that other log table is possible using the specified column.
* @return array
*/
public function getWaysToJoinToOtherLogTables()
{
return array();
}
/**
* Defines whether this table should be joined via a subselect. Return true if a complex join is needed. (eg when
* having visits and needing actions, or when having visits and needing conversions, or vice versa).
* @return bool
*/
public function shouldJoinWithSubSelect()
{
return false;
}
/**
* Defines a column that stores the date/time at which time an entry was written or updated. Setting this
* can help improve the performance of some archive queries. For example the log_link_visit_action table would define
* server_time while log_visit would define visit_last_action_time
* @return string
*/
public function getDateTimeColumn()
{
return '';
}
/**
* Returns the name of a log table that allows to join on a visit. Eg if there is a table "action", and it is not
* joinable with "visit" table, it can return "log_link_visit_action" to be able to join the action table on visit
* via this link table.
*
* In theory there could be case where it may be needed to join via two tables, so it could be needed at some
* point to return an array of tables here. not sure if we should handle this case just yet. Alternatively,
* once needed eg in LogQueryBuilder, we should maybe better call instead ->getLinkTableToBeAbleToJoinOnVisit()
* again on the returned table until we have found a table that can be joined with visit.
*
* @return string
*/
public function getLinkTableToBeAbleToJoinOnVisit()
{
return;
}
/**
* Get the names of the columns that represents the primary key. For example "idvisit" or "idlink_va". If the table
* defines the primary key based on multiple columns, you must specify them all
* (eg array('idvisit', 'idgoal', 'buster')).
*
* @return array
*/
public function getPrimaryKey()
{
return array();
}
}