diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/SegmentEditor/Model.php | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/plugins/SegmentEditor/Model.php b/plugins/SegmentEditor/Model.php index 2192e3ca58..7f312557f9 100644 --- a/plugins/SegmentEditor/Model.php +++ b/plugins/SegmentEditor/Model.php @@ -18,11 +18,10 @@ use Piwik\DbHelper; class Model { private static $rawPrefix = 'segment'; - private $table; - public function __construct() + protected function getTable() { - $this->table = Common::prefixTable(self::$rawPrefix); + return Common::prefixTable(self::$rawPrefix); } /** @@ -33,7 +32,7 @@ class Model */ public function getAllSegmentsAndIgnoreVisibility() { - $sql = "SELECT * FROM " . $this->table . " WHERE deleted = 0"; + $sql = "SELECT * FROM " . $this->getTable() . " WHERE deleted = 0"; $segments = $this->getDb()->fetchAll($sql); @@ -102,7 +101,7 @@ class Model public function deleteSegment($idSegment) { $db = $this->getDb(); - $db->delete($this->table, 'idsegment = ' . (int) $idSegment); + $db->delete($this->getTable(), 'idsegment = ' . (int) $idSegment); } public function updateSegment($idSegment, $segment) @@ -110,7 +109,7 @@ class Model $idSegment = (int) $idSegment; $db = $this->getDb(); - $db->update($this->table, $segment, "idsegment = $idSegment"); + $db->update($this->getTable(), $segment, "idsegment = $idSegment"); return true; } @@ -118,7 +117,7 @@ class Model public function createSegment($segment) { $db = $this->getDb(); - $db->insert($this->table, $segment); + $db->insert($this->getTable(), $segment); $id = $db->lastInsertId(); return $id; @@ -127,7 +126,7 @@ class Model public function getSegment($idSegment) { $db = $this->getDb(); - $segment = $db->fetchRow("SELECT * FROM " . $this->table . " WHERE idsegment = ?", $idSegment); + $segment = $db->fetchRow("SELECT * FROM " . $this->getTable() . " WHERE idsegment = ?", $idSegment); return $segment; } @@ -139,7 +138,7 @@ class Model private function buildQuerySortedByName($where) { - return "SELECT * FROM " . $this->table . " WHERE $where ORDER BY name ASC"; + return "SELECT * FROM " . $this->getTable() . " WHERE $where ORDER BY name ASC"; } public static function install() |