mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
insertall支持replace
This commit is contained in:
@@ -27,7 +27,7 @@ abstract class Builder
|
||||
// SQL表达式
|
||||
protected $selectSql = 'SELECT%DISTINCT% %FIELD% FROM %TABLE%%FORCE%%JOIN%%WHERE%%GROUP%%HAVING%%ORDER%%LIMIT% %UNION%%LOCK%%COMMENT%';
|
||||
protected $insertSql = '%INSERT% INTO %TABLE% (%FIELD%) VALUES (%DATA%) %COMMENT%';
|
||||
protected $insertAllSql = 'INSERT INTO %TABLE% (%FIELD%) %DATA% %COMMENT%';
|
||||
protected $insertAllSql = '%INSERT% INTO %TABLE% (%FIELD%) %DATA% %COMMENT%';
|
||||
protected $updateSql = 'UPDATE %TABLE% SET %SET% %JOIN% %WHERE% %ORDER%%LIMIT% %LOCK%%COMMENT%';
|
||||
protected $deleteSql = 'DELETE FROM %TABLE% %USING% %JOIN% %WHERE% %ORDER%%LIMIT% %LOCK%%COMMENT%';
|
||||
|
||||
@@ -719,9 +719,10 @@ abstract class Builder
|
||||
* @access public
|
||||
* @param array $dataSet 数据集
|
||||
* @param array $options 表达式
|
||||
* @param bool $replace 是否replace
|
||||
* @return string
|
||||
*/
|
||||
public function insertAll($dataSet, $options)
|
||||
public function insertAll($dataSet, $options, $replace = false)
|
||||
{
|
||||
// 获取合法的字段
|
||||
if ('*' == $options['field']) {
|
||||
@@ -754,8 +755,9 @@ abstract class Builder
|
||||
}
|
||||
$fields = array_map([$this, 'parseKey'], array_keys(reset($dataSet)));
|
||||
$sql = str_replace(
|
||||
['%TABLE%', '%FIELD%', '%DATA%', '%COMMENT%'],
|
||||
['%INSERT%', '%TABLE%', '%FIELD%', '%DATA%', '%COMMENT%'],
|
||||
[
|
||||
$replace ? 'REPLACE' : 'INSERT',
|
||||
$this->parseTable($options['table'], $options),
|
||||
implode(' , ', $fields),
|
||||
implode(' UNION ALL ', $values),
|
||||
|
||||
Reference in New Issue
Block a user