• R/O
  • SSH
  • HTTPS

jinrousiki: コミット


コミットメタ情報

リビジョン2284 (tree)
日時2018-12-07 02:53:58
作者umethyl

ログメッセージ

RoomDB::DeleteVote()

変更サマリ

差分

--- trunk/include/database/db_class.php (revision 2283)
+++ trunk/include/database/db_class.php (revision 2284)
@@ -330,6 +330,7 @@
330330 private $where_not = [];
331331 private $where_not_null = [];
332332 private $where_in = [];
333+ private $where_not_in = [];
333334 private $where_bool = [];
334335 private $where_not_true = [];
335336 private $group = [];
@@ -442,6 +443,11 @@
442443 return $this->StoreWhere('where_in', $column, $count);
443444 }
444445
446+ //WHERE 句登録 (NOT IN)
447+ public function WhereNotIn($column, $count) {
448+ return $this->StoreWhere('where_not_in', $column, $count);
449+ }
450+
445451 //WHERE 句登録 (NOT)
446452 public function WhereNot($column) {
447453 return $this->StoreWhere('where_not', $column);
@@ -557,11 +563,15 @@
557563
558564 $stack = [];
559565 foreach ($this->where as $value) {
560- $in_count = ArrayFilter::Get($this->where_in, $value);
561- $bool = ArrayFilter::Get($this->where_bool, $value);
562- if (false === is_null($in_count) && $in_count > 0) {
563- $in_list = array_fill(0, $in_count, '?');
564- $stack[] = $value . ' IN ' . Text::Quote(ArrayFilter::ToCSV($in_list));
566+ $count = ArrayFilter::Get($this->where_in, $value);
567+ $not_count = ArrayFilter::Get($this->where_not_in, $value);
568+ $bool = ArrayFilter::Get($this->where_bool, $value);
569+ if (false === is_null($count) && $count > 0) {
570+ $list = array_fill(0, $count, '?');
571+ $stack[] = $value . ' IN ' . Text::Quote(ArrayFilter::ToCSV($list));
572+ } elseif (false === is_null($not_count) && $not_count > 0) {
573+ $list = array_fill(0, $not_count, '?');
574+ $stack[] = $value . ' NOT IN ' . Text::Quote(ArrayFilter::ToCSV($list));
565575 } elseif (false === is_null($bool)) {
566576 $stack[] = $value . ' IS ' . ((true === $bool) ? self::ENABLE : self::DISABLE);
567577 } elseif (in_array($value, $this->where_not)) {
--- trunk/include/database/room_db_class.php (revision 2283)
+++ trunk/include/database/room_db_class.php (revision 2284)
@@ -158,26 +158,25 @@
158158 public static function DeleteVote() {
159159 if (is_null(DB::$ROOM->id)) return true;
160160
161- $query = 'DELETE FROM vote WHERE room_no = ? AND date = ?';
161+ $query = Query::Init()->Table('vote')->Delete()->Where(['room_no', 'date']);
162162 $list = [DB::$ROOM->id, DB::$ROOM->date];
163163 switch (DB::$ROOM->scene) {
164164 case RoomScene::DAY:
165- $query .= Query::AddWhere(['type', 'revote_count']);
165+ $query->Where(['type', 'revote_count']);
166166 array_push($list, VoteAction::VOTE_KILL, DB::$ROOM->revote_count);
167167 break;
168168
169169 case RoomScene::NIGHT:
170170 if (DB::$ROOM->IsDate(1)) {
171- $query .= ' AND type NOT IN (?, ?)';
171+ $query->WhereNotIn('type', 2);
172172 array_push($list, VoteAction::CUPID, VoteAction::DUELIST);
173173 } else {
174- $query .= ' AND type NOT IN (?)';
174+ $query->WhereNotIn('type', 1);
175175 $list[] = VoteAction::VOTE_KILL;
176176 }
177177 break;
178178 }
179-
180- DB::Prepare($query, $list);
179+ DB::Prepare($query->Build(), $list);
181180 return DB::Execute() && DB::Optimize('vote');
182181 }
183182
旧リポジトリブラウザで表示