/** * 添加数据 * @access public * @param string $table 表名 * @param array $data 数据 * @param bool $return_insert_id 是否返回 INSERT 操作产生的 ID 默认为false不返回 * @param bool $replace 是否为替换操作 默认为false * @param bool $silent 不显示错误 默认为flase(显示) * @return mixed */ public function insert($table, $data, $return_insert_id = false, $replace = false, $silent = false) { $sql = FDB::implodeFieldValue($data); $cmd = $replace ? 'REPLACE INTO' : 'INSERT INTO'; $table = FDB::table($table); $silent = $silent ? 'SILENT' : ''; $return = FDB::query("{$cmd} {$table} SET {$sql}", $silent); return $return_insert_id ? FDB::insertId() : $return; }
/** * 回复信息 * @param int $mlid 信件组编号 * @param int $fuid 发信会员编号 * @param string $fusername 发信会员名称 * @param string $message 信件内容 * @return int */ public function replyMsg($mlid, $fuid, $fusername, $message) { if (empty($mlid) || empty($fuid) || empty($fusername) || empty($message)) { return 0; } $mlist = FDB::fetchFirst("SELECT * FROM " . FDB::table('user_msg_list') . " WHERE mlid='{$mlid}'"); if (empty($mlist)) { return MSG_MLIST_NONE_ERROR; } if ($mlist['type'] == 1) { $users = explode('_', $mlist['min_max']); if ($users[0] == $fuid) { $tuid = $users[1]; } elseif ($users[1] == $fuid) { $tuid = $users[0]; } else { return MSG_PRIVILEGE_NONE_ERROR; } } $members = array(); $query = FDB::query("SELECT * FROM " . FDB::table('user_msg_member') . " WHERE mlid='{$mlid}'"); while ($member = FDB::fetch($query)) { $members[$member['uid']] = "('{$member['uid']}')"; } if (!isset($members[$fuid])) { return MSG_PRIVILEGE_NONE_ERROR; } $last_msg = htmlspecialchars(cutStr(clearExpress(trim($message)), 150)); $type = 0; FDB::query("INSERT INTO " . FDB::table('user_msg_index') . "(mlid) VALUES('{$mlid}')"); $miid = FDB::insertId(); FDB::query("INSERT INTO " . MessageService::getTablaName($mlid) . "(miid,mlid,uid,message,dateline,status) VALUES('{$miid}', '{$mlid}', '{$fuid}', '{$message}', '" . TIME_UTC . "', 0)"); if ($mlist['type'] == 1) { $msg_config = array('last_uid' => $fuid, 'last_user_name' => $fusername, 'last_msg' => $last_msg); $msg_config = addslashes(serialize($msg_config)); $result = FDB::query("INSERT INTO " . FDB::table('user_msg_member') . "(mlid, uid, is_new, num, last_update, last_dateline) VALUES('{$mlid}', '{$tuid}', '1', '1', '0', '" . TIME_UTC . "')", 'SILENT'); if (!$result) { FDB::query("UPDATE " . FDB::table('user_msg_member') . " SET is_new = 1, num = num + 1, last_dateline='" . TIME_UTC . "' WHERE mlid='{$mlid}' AND uid='{$tuid}'"); } FDB::query("UPDATE " . FDB::table('user_msg_member') . " SET is_new = 0, num = num + 1, last_update='" . TIME_UTC . "', last_dateline='" . TIME_UTC . "' WHERE mlid='{$mlid}' AND uid='{$fuid}'"); } else { } FDB::query("UPDATE " . FDB::table('user_msg_list') . " SET msg_config='{$msg_config}' WHERE mlid='{$mlid}'"); $result = FDB::query("INSERT INTO " . FDB::table('user_notice') . "(uid, type, num, create_time) VALUES('{$tuid}',5,1,'" . TIME_UTC . "')", 'SILENT'); if (!$result) { FDB::query("UPDATE " . FDB::table('user_notice') . " SET num = num + 1, create_time='" . TIME_UTC . "' WHERE uid='{$tuid}' AND type=5"); } return $miid; }