Overview

Packages

  • None
  • WxRobot
    • Admin
    • Cmd
    • CoreFunctions
    • Exends
    • Install
    • Table
    • Uninstall
    • WxSDK

Classes

  • ErrorCode
  • PKCS7Encoder
  • Prpcrypt
  • SHA1
  • Weixin_BaseCore
  • WeiXin_SDK
  • Weixin_Template
  • WXBizMsgCrypt
  • WxRobot_Admin
  • WxRobot_Admin_Menu_Extends
  • WxRobot_Admin_Menu_Instro
  • WxRobot_Admin_Menu_Menu
  • WxRobot_Admin_Menu_Records
  • WxRobot_Admin_Menu_Reply
  • WxRobot_Admin_Menu_Setting
  • WxRobot_Admin_Menu_Statistics
  • WxRobot_Cmd
  • WxRobot_Cmd_Event
  • WxRobot_Cmd_Event_User
  • WxRobot_Cmd_Text
  • WxRobot_Extends
  • WxRobot_Install
  • WxRobot_Robot
  • WxRobot_SDK
  • WxRobot_Table_Extends
  • WxRobot_Table_Menu
  • WxRobot_Table_Records
  • WxRobot_Table_Reply
  • WxRobot_Uninstall
  • WxRobot_Wp
  • XMLParse

Functions

  • wx_admin_log
  • wx_is_xml
  • wx_notice_msg
  • wx_parse_xml
  • wx_random_big_pic
  • wx_random_small_pic
  • wx_request_array
  • wx_request_decode
  • wx_request_is_encode
  • wx_request_xml
  • wx_send_encode
  • Overview
  • Package
  • Class
  1: <?php
  2: /**
  3:  * WxRobot Table Extends 
  4:  * 
  5:  * WP微信机器人 扩展表的相关功能
  6:  *
  7:  * @author      midoks
  8:  * @category    Table
  9:  * @package     WxRobot/Table
 10:  * @since       5.3.0
 11:  */
 12: 
 13: if ( ! defined( 'ABSPATH' ) ) {
 14:     exit;
 15: }
 16: 
 17: /**
 18:  *  WxRobot_Table_Reply 微信关键子设置模型
 19:  */
 20: class WxRobot_Table_Reply{
 21: 
 22:     /**
 23:      * 表前缀
 24:      */
 25:     public $table_prefix = 'midoks_';
 26: 
 27:     /**
 28:      * Table Extends Instance
 29:      */
 30:     public static $_instance = null;
 31:     
 32: 
 33:     /**
 34:      * WxRobot 扩展表类实例化
 35:      * 
 36:      * @return WxRobot_Table_Extends - Table Extends instance
 37:      */
 38:     public static function instance(){
 39:         if( is_null (self::$_instance)){
 40:             self::$_instance = new self();
 41:         }
 42:         return self::$_instance;
 43:     }
 44: 
 45:     /**
 46:      * 获取表名
 47:      *
 48:      * @return string
 49:      */
 50:     private function get_table_name(){
 51:         return $this->table_prefix.'weixin_robot_reply';
 52:     }
 53: 
 54:     /**
 55:      * 插入数据
 56:      *
 57:      * @param string $keyword 关键字
 58:      * @param string $reply   回复内容
 59:      * @param string $status  状态
 60:      * @param int    $type    类型
 61:      * @param int    $sort    排序
 62:      * return bool
 63:      */
 64:     public function insert_relpy($keyword, $relpy, $status, $type, $sort=1){
 65: 
 66:         global $wpdb;
 67:         $table_name = $this->get_table_name();
 68:         $time = date('Y-m-d H:i:s');
 69: 
 70:         $sql =  " INSERT INTO `{$table_name}` (`id`, `keyword`, `relpy`, `status`, `time`, `type`, `sort`)".
 71:                 " VALUES(null,'{$keyword}','{$relpy}','{$status}', '{$time}', '{$type}', '{$sort}') ";
 72: 
 73:         return $wpdb->query($sql);
 74:     }
 75: 
 76:     /**
 77:      * 获取回复数据
 78:      *
 79:      * @param string $kw 关键字
 80:      * @return mixed
 81:      */
 82:     public function weixin_get_relpy_data($kw=''){
 83:         global $wpdb;
 84:         $table_name = $this->get_table_name();
 85:         if(!empty($kw)){
 86:             $sql = "select `id`,`keyword`,`relpy`,`status`,`time`,`type`"
 87:                 ." from `{$table_name}` where `status`='1' and `keyword` like '%{$kw}%' order by `id` desc";
 88:         }else{
 89:             $sql = "select `id`,`keyword`,`relpy`,`status`,`time`,`type`"
 90:                 ." from `{$table_name}` where `status`='1' order by `id` desc";
 91:         }
 92:         $data  = $wpdb->get_results($sql);
 93:         if(empty($data)){
 94:             return false;
 95:         }else{
 96:             $arrs = array();
 97:             foreach($data as $k=>$v){
 98:                 $arr['id'] = $v->id;
 99:                 $arr['keyword'] = $v->keyword;
100:                 $arr['relpy'] = $v->relpy;
101:                 $arr['status'] = $v->status;
102:                 $arr['time'] = $v->time;
103:                 $arr['type'] = $v->type;
104:                 $arrs[] = $arr;
105:             }
106:             return $arrs;
107:         }       
108:     }
109: 
110: 
111:     /**
112:      * 删除关键字数据
113:      * 
114:      * @param int $id ID
115:      * @return bool
116:      */
117:     public function delete_relpy_id($id){
118:         global $wpdb;
119:         $table_name = $this->get_table_name();
120:         $sql = 'delete from `'.$table_name."` where `id`='{$id}'";
121:         return $wpdb->query($sql);
122:     }
123: 
124:     /**
125:      * 改变status状态
126:      *
127:      * @param int $id ID
128:      * @param int $status 状态值
129:      * @return bool
130:      */
131:     public function change_relpy_status($id, $status){
132:         global $wpdb;
133:         $table_name = $this->get_table_name();
134:         $sql = "UPDATE `{$table_name}` SET `status`='{$status}' WHERE `id`='{$id}'";
135:         return $wpdb->query($sql);
136:     }
137: 
138:     /**
139:      * 更改关键字回复内容
140:      *
141:      * @param int $id ID
142:      * @param string $keyword 关键字
143:      * @param string $reply  回复内容
144:      * @param string $type   类型
145:      */
146:     public function change_reply($id, $keyword, $relpy, $type){
147:         global $wpdb;
148:         $table_name = $this->get_table_name();
149:         $sql = "UPDATE `{$table_name}` SET `keyword`='{$keyword}',`relpy`='{$relpy}',`type`='{$type}' WHERE `id`='{$id}'";
150:         return $wpdb->query($sql);
151:     }
152: 
153: }
154: ?>
155: 
API documentation generated by ApiGen