Commit 508e8023369fd278a2d444afce6435583a5eabee

Authored by luoyanshou
1 parent ed629f9b

【留言板】 留言模型类 优化

trunk/Message/Common/Model/MessagesModel.class.php
... ... @@ -34,7 +34,7 @@ class MessagesModel extends AbstractModel
34 34 */
35 35 public function all_mess_list($page_option = null)
36 36 {
37   - $sql = "SELECT u_name,m.* FROM luoyanshou_luoyanshou,luoyanshou_messages m WHERE u_id = m.m_uid AND m.m_status <> 4 ORDER BY ins_date DESC ";
  37 + $sql = "SELECT u_name,m.* FROM luoyanshou_luoyanshou,luoyanshou_messages m WHERE u_id = m.m_uid AND m.m_status <> 4 ORDER BY m.ins_date DESC ";
38 38 return $this->_m->fetch_array($sql, [], $page_option);
39 39  
40 40 }
... ... @@ -75,8 +75,46 @@ class MessagesModel extends AbstractModel
75 75 $sql = "UPDATE luoyanshou_messages SET m_status= {$data['m_status']}, m_reason='{$data['m_reason']}', m_updated='{$time}' WHERE m_id={$mid} ";
76 76 return $this->_m->update($sql);
77 77 }
  78 + }
  79 +
  80 +
  81 + public function search_messes($conds=null, $page_option=null)
  82 + {
  83 + $where = '';
  84 + $sql1 ='';
78 85  
  86 + if ($conds != null && is_array($conds)) {
  87 + if ($conds['u_name'] != '') {
  88 + $where .= " u_name = '{$conds['u_name']}' OR ";
  89 + }
  90 + if ($conds['u_sex'] !='' ) {
  91 + $where .= " u_sex = {$conds['u_sex']} OR ";
  92 + }
  93 + if ($conds['u_tel'] != '') {
  94 + $where .= " u_tel = '{$conds['u_tel']}' OR ";
  95 + }
  96 + if ($conds['u_mail'] != '') {
  97 + $where .= " u_mail = '{$conds['u_mail']}' OR ";
  98 + }
  99 + if ($where != '') {
  100 + $where = substr(rtrim($where), 0, -2);
  101 + $sql1 .= " AND m.m_uid IN ( SELECT u_id FROM luoyanshou_luoyanshou WHERE {$where} ) ";
  102 + }
79 103  
  104 + if ($conds['m_title'] != '') {
  105 + if ($sql1 !='') {
  106 + $sql1 .= "OR m.m_title = '{$conds['m_title']}' ";
  107 + } else {
  108 + $sql1 .= "AND m.m_title = '{$conds['m_title']}' ";
  109 + }
  110 + }
  111 + }
  112 +
  113 + $sql = " SELECT u_name,m.* from luoyanshou_luoyanshou,luoyanshou_messages m WHERE m.m_uid=u_id AND m_status <> 4 ";
  114 + $order = " ORDER BY m.ins_date DESC ";
  115 + $sql .= $sql1.$order;
  116 +
  117 + return $this->_m->fetch_array($sql, [], $page_option);
80 118 }
81 119  
82 120 }
... ...