Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2013-07-23 11:52:15 +0400
committermattab <matthieu.aubry@gmail.com>2013-07-23 11:52:15 +0400
commit5104d94f3b2250f766b9c520e2da8da9b4cab2e9 (patch)
tree5f30daf7bc14373fb1bbd0504ce11a771dafc02f /core/Option.php
parentae4b1f4e38077b174e4df5b7d4513d63fe026a24 (diff)
Refs #4059 Work in progress: Conversion to use Namespaces of dozen more classes
Removed many Piwik_ functions, in Piwik 2 it is best practise to use the methods calls instead Todo: finish converting core/ classes + convert plugins/ classes to use \Piwik\Plugin namespace + fix build + Merge master
Diffstat (limited to 'core/Option.php')
-rw-r--r--core/Option.php42
1 files changed, 10 insertions, 32 deletions
diff --git a/core/Option.php b/core/Option.php
index 11f541bd55..653363bfc1 100644
--- a/core/Option.php
+++ b/core/Option.php
@@ -8,17 +8,18 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
use Piwik\Common;
/**
- * Piwik_Option provides a very simple mechanism to save/retrieve key-values pair
+ * Option provides a very simple mechanism to save/retrieve key-values pair
* from the database (persistent key-value datastore).
*
* This is useful to save Piwik-wide preferences, configuration values.
*
* @package Piwik
*/
-class Piwik_Option
+class Option
{
/**
* @var array
@@ -32,14 +33,14 @@ class Piwik_Option
/**
* Singleton instance
- * @var self
+ * @var \Piwik\Option
*/
static private $instance = null;
/**
* Returns Singleton instance
*
- * @return Piwik_Option
+ * @return \Piwik\Option
*/
static public function getInstance()
{
@@ -68,7 +69,7 @@ class Piwik_Option
if (isset($this->all[$name])) {
return $this->all[$name];
}
- $value = Piwik_FetchOne('SELECT option_value ' .
+ $value = Db::fetchOne('SELECT option_value ' .
'FROM `' . Common::prefixTable('option') . '`' .
'WHERE option_name = ?', $name);
if ($value === false) {
@@ -88,7 +89,7 @@ class Piwik_Option
public function set($name, $value, $autoLoad = 0)
{
$autoLoad = (int)$autoLoad;
- Piwik_Query('INSERT INTO `' . Common::prefixTable('option') . '` (option_name, option_value, autoload) ' .
+ Db::query('INSERT INTO `' . Common::prefixTable('option') . '` (option_name, option_value, autoload) ' .
' VALUES (?, ?, ?) ' .
' ON DUPLICATE KEY UPDATE option_value = ?',
array($name, $value, $autoLoad, $value));
@@ -111,7 +112,7 @@ class Piwik_Option
$bind[] = $value;
}
- Piwik_Query($sql, $bind);
+ Db::query($sql, $bind);
$this->clearCache();
}
@@ -133,7 +134,7 @@ class Piwik_Option
$bind[] = $value;
}
- Piwik_Query($sql, $bind);
+ Db::query($sql, $bind);
$this->clearCache();
}
@@ -149,7 +150,7 @@ class Piwik_Option
return;
}
- $all = Piwik_FetchAll('SELECT option_value, option_name
+ $all = Db::fetchAll('SELECT option_value, option_name
FROM `' . Common::prefixTable('option') . '`
WHERE autoload = 1');
foreach ($all as $option) {
@@ -171,26 +172,3 @@ class Piwik_Option
$this->all = array();
}
}
-
-/**
- * Returns the option value for the requested option $name
- *
- * @param string $name Key
- * @return string|false Value or false, if not found
- */
-function Piwik_GetOption($name)
-{
- return Piwik_Option::getInstance()->get($name);
-}
-
-/**
- * Sets the option value in the database
- *
- * @param string $name
- * @param string $value
- * @param int $autoLoad if set to 1, this option value will be automatically loaded; should be set to 1 for options that will always be used in the Piwik request.
- */
-function Piwik_SetOption($name, $value, $autoLoad = 0)
-{
- Piwik_Option::getInstance()->set($name, $value, $autoLoad);
-}