System_config_model.php 1022 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. if (!defined('BASEPATH'))exit('No direct script access allowed');
  3. include_once(FCPATH . 'application/models/Base_model.php');
  4. class System_config_model extends Base_model {
  5. protected $table = 'system_config';
  6. public function __construct() {
  7. parent::__construct();
  8. }
  9. // 获取系统信息
  10. public function get_system_config($key){
  11. if (empty($key)) {
  12. return '';
  13. }
  14. $data = $this->db->select('value')->where('key',$key)->get($this->table)->row_array();
  15. return $data['value'];
  16. }
  17. // 设置系统信息
  18. public function set_system_config($key,$value){
  19. if (empty($key) || empty($value)) {
  20. return '';
  21. }
  22. $num = $this->db->where('key',$key)->get($this->table)->num_rows();
  23. if (empty($num)) {
  24. $this->db->insert($this->table,array('key'=>$key,'value'=>$value));
  25. }else{
  26. $this->db->where('key',$key)->update($this->table,array('value'=>$value));
  27. }
  28. return;
  29. }
  30. }
  31. ?>