diff options
author | diosmosis <benakamoorthi@fastmail.fm> | 2014-03-21 14:09:58 +0400 |
---|---|---|
committer | diosmosis <benakamoorthi@fastmail.fm> | 2014-03-21 14:14:02 +0400 |
commit | e9be39c60cf323d504b28b85bb8d4a4f6a70ba42 (patch) | |
tree | 149a9748d14c28eda5ac5ec782cdb581c801aa37 /core/Option.php | |
parent | 1581aa76a3e31dba957dbee89a5be9d846a5aa1e (diff) |
Allow getting options whose names are like a given pattern.
Diffstat (limited to 'core/Option.php')
-rw-r--r-- | core/Option.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/core/Option.php b/core/Option.php index 27f6c367c2..63910cf7e5 100644 --- a/core/Option.php +++ b/core/Option.php @@ -47,6 +47,18 @@ class Option } /** + * Returns option values for options whose names are like a given pattern. + * + * @param string $namePattern The pattern used in the SQL `LIKE` expression + * used to SELECT options. + * @return array Array mapping option names with option values. + */ + public static function getLike($namePattern) + { + return self::getInstance()->getNameLike($namePattern); + } + + /** * Sets an option value by name. * * @param string $name The option name. @@ -188,6 +200,18 @@ class Option $this->clearCache(); } + protected function getNameLike($name) + { + $sql = 'SELECT option_name, option_value FROM ' . Common::prefixTable('option') . ' WHERE option_name LIKE ?'; + $bind = array($name); + + $result = array(); + foreach (Db::fetchAll($sql, $bind) as $row) { + $result[$row['option_name']] = $row['option_value']; + } + return $result; + } + /** * Initialize cache with autoload settings. * |