mb_home.model.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * 手机端首页
  4. *
  5. *
  6. *
  7. *
  8. */
  9. defined('InShopNC') or exit('Access Invalid!');
  10. class mb_homeModel extends Model{
  11. public function __construct() {
  12. parent::__construct('mb_home');
  13. }
  14. /**
  15. * 列表
  16. *
  17. * @param array $condition 查询条件
  18. * @param int $page 分页数
  19. * @param string $order 排序
  20. * @param string $field 字段
  21. * @return array
  22. */
  23. public function getMbHomeList($condition, $page = null, $order = 'h_type asc', $field = '*') {
  24. $h_list = $this->field($field)->where($condition)->page($page)->order($order)->select();
  25. //整理图片链接
  26. if (is_array($h_list)){
  27. foreach ($h_list as $k => $v){
  28. if (!empty($v['h_img'])){
  29. $h_list[$k]['h_img_url'] = UPLOAD_SITE_URL.'/'.ATTACH_MOBILE.'/home'.'/'.$v['h_img'];
  30. }
  31. }
  32. }
  33. return $h_list;
  34. }
  35. /**
  36. * 取单个内容
  37. *
  38. * @param int $id ID
  39. * @return array 数组类型的返回结果
  40. */
  41. public function getMbHomeInfoByID($id){
  42. if (intval($id) > 0){
  43. $condition = array('h_id' => $id);
  44. $result = $this->where($condition)->find();
  45. return $result;
  46. }else {
  47. return false;
  48. }
  49. }
  50. /**
  51. * 更新信息
  52. *
  53. * @param array $param 更新数据
  54. * @param array $condition 条件
  55. * @return bool 布尔类型的返回结果
  56. */
  57. public function editMbHome($param, $condition){
  58. return $this->where($condition)->update($param);
  59. }
  60. }