Skip to content
This repository has been archived by the owner on Jan 4, 2020. It is now read-only.

修正addAll()的隐患bug #475

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ThinkPHP/Library/Think/Db/Driver.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -967,9 +967,11 @@ public function insertAll($dataSet, $options = array(), $replace = false)
}
}
}
$values[] = 'SELECT ' . implode(',', $value);
// $values[] = 'SELECT ' . implode(',', $value);
$values[] = '('.implode(',', $value).')';
}
$sql = 'INSERT INTO ' . $this->parseTable($options['table']) . ' (' . implode(',', $fields) . ') ' . implode(' UNION ALL ', $values);
$sql = 'INSERT INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') values'.implode(',',$values);
// $sql = 'INSERT INTO ' . $this->parseTable($options['table']) . ' (' . implode(',', $fields) . ') ' . implode(' UNION ALL ', $values);
$sql .= $this->parseComment(!empty($options['comment']) ? $options['comment'] : '');
return $this->execute($sql, !empty($options['fetch_sql']) ? true : false);
}
Expand Down