upload_album.model.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <?php
  2. /**
  3. * 上传文件模型
  4. *
  5. *
  6. *
  7. *
  8. */
  9. defined('InShopNC') or exit('Access Invalid!');
  10. class upload_albumModel{
  11. /**
  12. * 列表
  13. *
  14. * @param array $condition 检索条件
  15. * @return array 数组结构的返回结果
  16. */
  17. public function getUploadList($condition){
  18. $condition_str = $this->_condition($condition);
  19. $param = array();
  20. $param['table'] = 'album_pic';
  21. $param['where'] = $condition_str;
  22. $result = Db::select($param);
  23. return $result;
  24. }
  25. /**
  26. * 构造检索条件
  27. *
  28. * @param int $id 记录ID
  29. * @return string 字符串类型的返回结果
  30. */
  31. private function _condition($condition){
  32. $condition_str = '';
  33. if($condition['apic_name'] != '') {
  34. $condition_str .= " and apic_name='{$condition['pic_name']}'";
  35. }
  36. if($condition['apic_tag'] != '') {
  37. $condition_str .= " and apic_tag='{$condition['apic_tag']}'";
  38. }
  39. if($condition['aclass_id'] != '') {
  40. $condition_str .= " and aclass_id='{$condition['aclass_id']}'";
  41. }
  42. if($condition['apic_cover'] != '') {
  43. $condition_str .= " and apic_cover='{$condition['apic_cover']}'";
  44. }
  45. if($condition['apic_size'] != '') {
  46. $condition_str .= " and apic_size='{$condition['apic_size']}'";
  47. }
  48. if($condition['store_id'] != '') {
  49. $condition_str .= " and store_id='{$condition['store_id']}'";
  50. }
  51. if($condition['upload_time'] != '') {
  52. $condition_str .= " and upload_time='{$condition['upload_time']}'";
  53. }
  54. return $condition_str;
  55. }
  56. /**
  57. * 取单个内容
  58. *
  59. * @param int $id 分类ID
  60. * @return array 数组类型的返回结果
  61. */
  62. public function getOneUpload($id){
  63. if (intval($id) > 0){
  64. $param = array();
  65. $param['table'] = 'album_pic';
  66. $param['field'] = 'apic_id';
  67. $param['value'] = intval($id);
  68. $result = Db::getRow($param);
  69. return $result;
  70. }else {
  71. return false;
  72. }
  73. }
  74. /**
  75. * 新增
  76. *
  77. * @param array $param 参数内容
  78. * @return bool 布尔类型的返回结果
  79. */
  80. public function add($param){
  81. if (empty($param)){
  82. return false;
  83. }
  84. if (is_array($param)){
  85. $result = Db::insert('album_pic',$param);
  86. return $result;
  87. }else {
  88. return false;
  89. }
  90. }
  91. /**
  92. * 更新信息
  93. *
  94. * @param array $param 更新数据
  95. * @return bool 布尔类型的返回结果
  96. */
  97. public function update($param){
  98. if (empty($param)){
  99. return false;
  100. }
  101. if (is_array($param)){
  102. $tmp = array();
  103. foreach ($param as $k => $v){
  104. $tmp[$k] = $v;
  105. }
  106. $where = " apic_id = '{$param['apic_id']}'";
  107. $result = Db::update('album_pic',$tmp,$where);
  108. return $result;
  109. }else {
  110. return false;
  111. }
  112. }
  113. /**
  114. * 更新信息
  115. *
  116. * @param array $param 更新数据
  117. * @param array $conditionarr 条件数组
  118. * @return bool 布尔类型的返回结果
  119. */
  120. public function updatebywhere($param,$conditionarr){
  121. if (empty($param)){
  122. return false;
  123. }
  124. if (is_array($param)){
  125. //条件
  126. $condition_str = $this->_condition($conditionarr);
  127. //更新信息
  128. $tmp = array();
  129. foreach ($param as $k => $v){
  130. $tmp[$k] = $v;
  131. }
  132. $result = Db::update('album_pic',$tmp,$condition_str);
  133. return $result;
  134. }else {
  135. return false;
  136. }
  137. }
  138. /**
  139. * 删除分类
  140. *
  141. * @param int $id 记录ID
  142. * @return bool 布尔类型的返回结果
  143. */
  144. public function del($id){
  145. if (intval($id) > 0){
  146. $where = " apic_id = '". intval($id) ."'";
  147. $result = Db::delete('album_pic',$where);
  148. return $result;
  149. }else {
  150. return false;
  151. }
  152. }
  153. /**
  154. * 删除上传图片信息
  155. * @param mixed $id 删除上传图片记录编号
  156. */
  157. public function dropUploadById($id){
  158. if(empty($id)) {
  159. return false;
  160. }
  161. $condition_str = ' 1=1 ';
  162. if (is_array($id) && count($id)>0){
  163. $idStr = implode(',',$id);
  164. $condition_str .= " and apic_id in({$idStr}) ";
  165. }else {
  166. $condition_str .= " and apic_id = {$id} ";
  167. }
  168. $result = Db::delete('album_pic',$condition_str);
  169. return $result;
  170. }
  171. //
  172. //
  173. // /**
  174. // * 等级对应的店铺列表
  175. // *
  176. // * @param array $condition 检索条件
  177. // * @param obj $page 分页
  178. // * @return array 数组结构的返回结果
  179. // */
  180. // public function getGradeShopList($condition,$page){
  181. // $condition_str = $this->_conditionShop($condition);
  182. // $param = array(
  183. // 'table'=>'store_grade,store',
  184. // 'field'=>'store_grade.*,store.*',
  185. // 'where'=>$condition_str,
  186. // 'join_type'=>'left join',
  187. // 'join_on'=>array(
  188. // 'store_grade.sg_id = store.grade_id',
  189. // )
  190. // );
  191. // $result = Db::select($param,$page);
  192. // return $result;
  193. // }
  194. //
  195. // /**
  196. // * 构造 店铺列表 检索条件
  197. // *
  198. // * @param array $condition 检索条件
  199. // * @return string 字符串类型的返回结果
  200. // */
  201. // private function _conditionShop($condition){
  202. // $condition_str = '';
  203. //
  204. // if ($condition['sg_id'] != ''){
  205. // $condition_str .= " and store_grade.sg_id = '". $condition['sg_id'] ."'";
  206. // }
  207. //
  208. // return $condition_str;
  209. // }
  210. }