私は CodeIgniter で開発していますが、しばらくして、以下の mySQL ログが示すように、すべてのクエリが 2 回実行されていることに気付きました。
55 Query SELECT user_display FROM user WHERE user_id=1
55 Query SELECT user_display FROM user WHERE user_id=1
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=95
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=95
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=95
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=95
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=95
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=95
55 Query SELECT addon_name FROM addon WHERE addon_id='1' OR addon_id='4'
55 Query SELECT addon_name FROM addon WHERE addon_id='1' OR addon_id='4'
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=95
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=95
55 Query SELECT skill_name FROM skill WHERE skill_id='2' OR skill_id='4' OR skill_id='13'
55 Query SELECT skill_name FROM skill WHERE skill_id='2' OR skill_id='4' OR skill_id='13'
55 Query SELECT user_display FROM user WHERE user_id=2
55 Query SELECT user_display FROM user WHERE user_id=2
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=9
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=9
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=9
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=9
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=9
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=9
55 Query SELECT addon_name FROM addon WHERE addon_id='1'
55 Query SELECT addon_name FROM addon WHERE addon_id='1'
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=9
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=9
55 Query SELECT skill_name FROM skill WHERE skill_id='1' OR skill_id='4'
55 Query SELECT skill_name FROM skill WHERE skill_id='1' OR skill_id='4'
55 Query SELECT user_display FROM user WHERE user_id=2
55 Query SELECT user_display FROM user WHERE user_id=2
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=16
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=16
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=16
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=16
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=16
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=16
55 Query SELECT addon_name FROM addon WHERE addon_id='2' OR addon_id='4'
55 Query SELECT addon_name FROM addon WHERE addon_id='2' OR addon_id='4'
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=16
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=16
55 Query SELECT skill_name FROM skill WHERE skill_id='16'
55 Query SELECT skill_name FROM skill WHERE skill_id='16'
55 Query SELECT user_display FROM user WHERE user_id=1
55 Query SELECT user_display FROM user WHERE user_id=1
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=68
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=68
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=68
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=68
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=68
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=68
55 Query SELECT addon_name FROM addon WHERE addon_id='7'
55 Query SELECT addon_name FROM addon WHERE addon_id='7'
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=68
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=68
55 Query SELECT skill_name FROM skill WHERE skill_id='1' OR skill_id='3'
55 Query SELECT skill_name FROM skill WHERE skill_id='1' OR skill_id='3'
55 Query SELECT user_display FROM user WHERE user_id=1
55 Query SELECT user_display FROM user WHERE user_id=1
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=79
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=79
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=79
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=79
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=79
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=79
55 Query SELECT addon_name FROM addon WHERE addon_id='4'
55 Query SELECT addon_name FROM addon WHERE addon_id='4'
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=79
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=79
55 Query SELECT skill_name FROM skill WHERE skill_id='2' OR skill_id='4' OR skill_id='6'
55 Query SELECT skill_name FROM skill WHERE skill_id='2' OR skill_id='4' OR skill_id='6'
55 Query SELECT user_display FROM user WHERE user_id=1
55 Query SELECT user_display FROM user WHERE user_id=1
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=86
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=86
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=86
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=86
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=86
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=86
55 Query SELECT addon_name FROM addon WHERE addon_id='2' OR addon_id='3'
55 Query SELECT addon_name FROM addon WHERE addon_id='2' OR addon_id='3'
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=86
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=86
55 Query SELECT skill_name FROM skill WHERE skill_id='8' OR skill_id='13'
55 Query SELECT skill_name FROM skill WHERE skill_id='8' OR skill_id='13'
55 Query SELECT user_display FROM user WHERE user_id=1
55 Query SELECT user_display FROM user WHERE user_id=1
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=92
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=92
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=92
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=92
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=92
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=92
55 Query SELECT addon_name FROM addon WHERE addon_id='3' OR addon_id='4' OR addon_id='5' OR addon_id='8'
55 Query SELECT addon_name FROM addon WHERE addon_id='3' OR addon_id='4' OR addon_id='5' OR addon_id='8'
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=92
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=92
55 Query SELECT skill_name FROM skill WHERE skill_id='3' OR skill_id='6' OR skill_id='19'
55 Query SELECT skill_name FROM skill WHERE skill_id='3' OR skill_id='6' OR skill_id='19'
55 Query SELECT user_display FROM user WHERE user_id=2
55 Query SELECT user_display FROM user WHERE user_id=2
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=12
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=12
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=12
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=12
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=12
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=12
55 Query SELECT addon_name FROM addon WHERE addon_id='3' OR addon_id='4' OR addon_id='8'
55 Query SELECT addon_name FROM addon WHERE addon_id='3' OR addon_id='4' OR addon_id='8'
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=12
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=12
55 Query SELECT skill_name FROM skill WHERE skill_id='11'
55 Query SELECT skill_name FROM skill WHERE skill_id='11'
55 Query SELECT user_display FROM user WHERE user_id=1
55 Query SELECT user_display FROM user WHERE user_id=1
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=34
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=34
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=34
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=34
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=34
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=34
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=34
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=34
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=34
55 Query SELECT skill_name FROM skill WHERE skill_id='3'
55 Query SELECT skill_name FROM skill WHERE skill_id='3'
55 Query SELECT user_display FROM user WHERE user_id=1
55 Query SELECT user_display FROM user WHERE user_id=1
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=74
55 Query SELECT TIMEDIFF(NOW(),contest_create) FROM contest WHERE contest_id=74
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=74
55 Query SELECT TIMEDIFF(ADDDATE(contest_create, INTERVAL contest_duration DAY),NOW()) FROM contest WHERE contest_id=74
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=74
55 Query SELECT add_addon_id FROM addon_contest WHERE add_contest_id=74
55 Query SELECT addon_name FROM addon WHERE addon_id='1'
55 Query SELECT addon_name FROM addon WHERE addon_id='1'
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=74
55 Query SELECT required_skill_id FROM skill_contest WHERE required_contest_id=74
55 Query SELECT skill_name FROM skill WHERE skill_id='2'
55 Query SELECT skill_name FROM skill WHERE skill_id='2'
55 Query SELECT skill_name FROM skill WHERE skill_status=2
55 Query SELECT skill_name FROM skill WHERE skill_status=2
55 Quit
問題は、いくつかの INSERT クエリが実行されると、すべての情報が 2 回挿入され、クエリの順序を見ると、モデルを 2 回呼び出していないと結論付けることができますが、"$this->db-> を呼び出すとquery($sql)" これは mySQL に 2 回送信されています。CodeIgniter のデータベース設定が間違っているのかもしれません。