Configuration.class.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. class Configuration extends SQLiteEntity{
  3. protected $id,$key,$value;
  4. protected $TABLE_NAME = 'configuration';
  5. protected $CLASS_NAME = 'Configuration';
  6. protected $object_fields =
  7. array(
  8. 'id'=>'key',
  9. 'key'=>'longstring',
  10. 'value'=>'longstring'
  11. );
  12. function __construct(){
  13. parent::__construct();
  14. }
  15. public function get($key){
  16. $configurationManager = new Configuration();
  17. $config = $configurationManager->load(array('key'=>$key));
  18. return (is_object($config)?$config->getValue():'');
  19. }
  20. public function put($key,$value){
  21. $configurationManager = new Configuration();
  22. $config = $configurationManager->load(array('key'=>$key));
  23. $config = (!$config?new Configuration():$config);
  24. $config->setKey($key);
  25. $config->setValue($value);
  26. $config->save();
  27. }
  28. function getId(){
  29. return $this->id;
  30. }
  31. function getKey(){
  32. return $this->key;
  33. }
  34. function setKey($key){
  35. $this->key = $key;
  36. }
  37. function getValue(){
  38. return $this->value;
  39. }
  40. function setValue($value){
  41. $this->value = $value;
  42. }
  43. }
  44. ?>