• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

コミットメタ情報

リビジョン112f2316c2b09094f162b73cf28f1cdd4535e73b (tree)
日時2017-06-02 00:17:28
作者umorigu <umorigu@gmai...>
コミッターumorigu

ログメッセージ

BugTrack/2422 Counter plugin supports MySQL

変更サマリ

差分

--- a/plugin/counter.inc.php
+++ b/plugin/counter.inc.php
@@ -16,7 +16,10 @@ define('PLUGIN_COUNTER_USE_DB', 0);
1616 define('PLUGIN_COUNTER_DB_CONNECT_STRING', 'sqlite:counter/counter.db');
1717 define('PLUGIN_COUNTER_DB_USERNAME', '');
1818 define('PLUGIN_COUNTER_DB_PASSWORD', '');
19-define('PLUGIN_COUNTER_DB_OPTIONS', null);
19+$plugin_counter_db_options = null;
20+// For MySQL
21+// $plugin_counter_db_options = array(PDO::MYSQL_ATTR_INIT_COMMAND =>
22+// "SET NAMES utf8mb4 COLLATE utf8mb4_bin");
2023
2124 define('PLUGIN_COUNTER_DB_TABLE_NAME_PREFIX', '');
2225
@@ -59,7 +62,7 @@ EOD;
5962 // Return a summary
6063 function plugin_counter_get_count($page)
6164 {
62- global $vars;
65+ global $vars, $plugin_counter_db_options;
6366 static $counters = array();
6467 static $default;
6568 $page_counter_t = PLUGIN_COUNTER_DB_TABLE_NAME_PREFIX . 'page_counter';
@@ -88,7 +91,7 @@ function plugin_counter_get_count($page)
8891 try {
8992 $pdo = new PDO(PLUGIN_COUNTER_DB_CONNECT_STRING,
9093 PLUGIN_COUNTER_DB_USERNAME, PLUGIN_COUNTER_DB_PASSWORD,
91- PLUGIN_COUNTER_DB_OPTIONS);
94+ $plugin_counter_db_options);
9295 $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
9396 $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
9497 $pdo->setAttribute(PDO::ATTR_TIMEOUT, 5);
@@ -204,15 +207,16 @@ function plugin_counter_get_count($page)
204207 * php -r "include 'plugin/counter.inc.php'; plugin_counter_tool_setup_table();"
205208 */
206209 function plugin_counter_tool_setup_table() {
210+ global $plugin_counter_db_options;
207211 $page_counter_t = PLUGIN_COUNTER_DB_TABLE_NAME_PREFIX . 'page_counter';
208212 $pdo = new PDO(PLUGIN_COUNTER_DB_CONNECT_STRING,
209213 PLUGIN_COUNTER_DB_USERNAME, PLUGIN_COUNTER_DB_PASSWORD,
210- PLUGIN_COUNTER_DB_OPTIONS);
214+ $plugin_counter_db_options);
211215 $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
212216 $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
213217 $r = $pdo->exec(
214218 "CREATE TABLE $page_counter_t (
215- page_name VARCHAR(300) PRIMARY KEY,
219+ page_name VARCHAR(190) PRIMARY KEY,
216220 total INTEGER NOT NULL,
217221 update_date VARCHAR(20) NOT NULL,
218222 today_viewcount INTEGER NOT NULL,