PageRenderTime 50ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/core/classes/Options.php

https://github.com/allanfreitas/CandyCMS
PHP | 41 lines | 22 code | 11 blank | 8 comment | 4 complexity | 3d37dea2ae54ae2455b5b868dae73c24 MD5 | raw file
  1. <?php
  2. /**
  3. * @package CandyCMS
  4. * @version 1.0
  5. * @since 0.1
  6. * @copyright Copyright 2012 (C) Cocoon Design Ltd. - All Rights Reserved
  7. *
  8. * Functions for loading from the Options table in the DB
  9. */
  10. class Options {
  11. public function __invoke($name = null, $default = null) {
  12. if (!is_null($name)) {
  13. static $options;
  14. if(!isset($options)) {
  15. $options = CandyDB::keyvalue('SELECT option_key, option_value FROM '. DB_PREFIX .'options');
  16. }
  17. if(isset($options[$name])) {
  18. return $options[$name];
  19. } else {
  20. return $default;
  21. }
  22. }
  23. }
  24. public function set($name, $value) {
  25. CandyDB::q('INSERT INTO ' . DB_PREFIX . 'options (option_key, option_value) VALUES (:name, :value) ON DUPLICATE KEY UPDATE option_value = :value', compact('name', 'value'));
  26. }
  27. public function test(){
  28. echo 'testing 123';
  29. }
  30. }