DiydataModel.class.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. *
  6. * @author J_da
  7. *
  8. */
  9. namespace Seller\Model;
  10. class DiydataModel{
  11. public function update($data)
  12. {
  13. $sql = 'TRUNCATE '. C('DB_PREFIX'). 'lionfish_comshop_diydata';
  14. $rs = M()->execute($sql);
  15. // $rs = M('lionfish_comshop_diydata')->where( 'id > 0' )->delete();
  16. foreach($data as $key => $value)
  17. {
  18. $name = $value->controller;
  19. $value = json_encode($value);
  20. $ins_data = array();
  21. $ins_data['name'] = $name;
  22. $ins_data['value'] = serialize($value);
  23. M('lionfish_comshop_diydata')->add($ins_data);
  24. }
  25. $this->get_all_config(true);
  26. }
  27. public function get_all_config($is_parse = false)
  28. {
  29. // $data = S('_get_all_diy_data');
  30. $data = array();
  31. if (empty($data) || $is_parse) {
  32. $all_list = M('lionfish_comshop_diydata')->select();
  33. if (empty($all_list)) {
  34. $data = array();
  35. }else{
  36. $data = array();
  37. foreach($all_list as $val)
  38. {
  39. $data[] = json_decode(unserialize($val['value']));
  40. }
  41. }
  42. S('_get_all_diy_data', $data);
  43. }
  44. return $data;
  45. }
  46. }
  47. ?>