function query($sql, $is_read = true) { $result = mysql_query($sql, self::$conn[$this->i]); $log = config('log', 'mysql'); $log['is_record_sql'] and logger::sql($sql, $is_read); if ($result) { return $result; } $info = $sql . ' {' . mysql_error() . '}'; $log['is_record_exception'] and logger::exception('mysql', $info); throw new Exception($info, 104); }
$MessageGroupId = empty($mid) ? $appmsgid : $mid; } if (empty($MessageGroupId)) { $MessageGroupId = 'null'; } if (empty($commMsgInfoId)) { $commMsgInfoId = 'null'; } $sql = "\nINSERT INTO babysitter_weixin_message_info_fetch_history\n(weixin_id, comm_msg_info_id, message_group_id, message_item_index, is_multi, title, content_url, publish_time, read_num, like_num, fetched_time)\nVALUES\n(\n'{$weixinID}'\n, {$commMsgInfoId}\n, {$MessageGroupId}\n, {$msgInfoOneEntry->MessageItemIndex}\n, {$isMulti}\n, '{$title}'\n, '{$contentURL}'\n, from_unixtime({$msgInfoOneEntry->PublishTimestamp})\n, {$readNum}\n, {$likeNum}\n, from_unixtime({$msgInfoOneEntry->CrawlTimestamp})\n);\n "; $sqlList[] = trim(preg_replace("/[\\r\\n]/", " ", $sql)); } $dbLink->close(); $sqlOutput = PHP_EOL . implode(PHP_EOL, $sqlList); logger::sql($sqlOutput); logger::sql(PHP_EOL); logger::sql("\nset session sql_safe_updates = 0;\nupdate babysitter_weixin_message_info_fetch_history h left join babysitter_account a on a.weibo_id = h.weixin_id and a.weibo_type = 9 set h.account_id = a.account_id where h.account_id is null;\n"); logger::info($sqlOutput); logger::info("END."); class utils { public static function removeNonUtf8($string) { $regex = <<<'END' / ( (?: [\x00-\x7F] # single-byte sequences 0xxxxxxx | [\xC0-\xDF][\x80-\xBF] # double-byte sequences 110xxxxx 10xxxxxx | [\xE0-\xEF][\x80-\xBF]{2} # triple-byte sequences 1110xxxx 10xxxxxx * 2 | [\xF0-\xF7][\x80-\xBF]{3} # quadruple-byte sequence 11110xxx 10xxxxxx * 3 ){1,100} # ...one or more times )