DiydataModel.class.php 1.3 KB

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