Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method CDbCommandBuilder:: createMultipleInsertCommandWithIgnore added #4545

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
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
13 changes: 12 additions & 1 deletion framework/db/schema/CDbCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,18 @@ public function createMultipleInsertCommand($table,array $data)
return $this->composeMultipleInsertCommand($table,$data);
}

/**
/**
* Creates a conflict ignorant multiple INSERT command (should be overridden).
* @param mixed $table the table schema ({@link CDbTableSchema}) or the table name (string).
* @param array[] $data list data to be inserted, each value should be an array in format (column name=>column value).
* @return CDbCommand multiple insert command
* @since 1.1.30
*/
public function createMultipleInsertCommandWithIgnore($table, array $data) {
return $this->createMultipleInsertCommand($table, $data);
}

/**
* Creates a multiple INSERT command.
* This method compose the SQL expression via given part templates, providing ability to adjust
* command for different SQL syntax.
Expand Down
14 changes: 14 additions & 0 deletions framework/db/schema/mysql/CMysqlCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,18 @@ public function applyLimit($sql,$limit,$offset)
$limit=PHP_INT_MAX;
return parent::applyLimit($sql,$limit,$offset);
}

/**
* Creates a conflict ignorant multiple INSERT command.
* @param mixed $table the table schema ({@link CDbTableSchema}) or the table name (string).
* @param array[] $data list data to be inserted, each value should be an array in format (column name=>column value).
* @return CDbCommand multiple insert command
* @throws CDbException
* @since 1.1.30
*/
public function createMultipleInsertCommandWithIgnore($table, array $data) {
return $this->composeMultipleInsertCommand($table, $data, array(
"main" => "INSERT INTO {{tableName}} ({{columnInsertNames}}) VALUES {{rowInsertValues}} ON DUPLICATE KEY DO NOTHING",
));
}
}
14 changes: 14 additions & 0 deletions framework/db/schema/pgsql/CPgsqlCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,18 @@ protected function getIntegerPrimaryKeyDefaultValue()
{
return 'DEFAULT';
}

/**
* Creates a conflict ignorant multiple INSERT command.
* @param mixed $table the table schema ({@link CDbTableSchema}) or the table name (string).
* @param array[] $data list data to be inserted, each value should be an array in format (column name=>column value).
* @return CDbCommand multiple insert command
* @throws CDbException
* @since 1.1.30
*/
public function createMultipleInsertCommandWithIgnore($table, array $data) {
return $this->composeMultipleInsertCommand($table, $data, array(
"main" => "INSERT INTO {{tableName}} ({{columnInsertNames}}) VALUES {{rowInsertValues}} ON CONFLICT DO NOTHING",
));
}
}