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

Drop single dimensional array support for data array in insert function #8287

Open
wants to merge 1 commit into
base: release-3.0
Choose a base branch
from
Open
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
5 changes: 0 additions & 5 deletions Sources/Db/APIs/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,6 @@ public function insert(string $method, string $table, array $columns, array $dat
}
}

// Inserting data as a single row can be done as a single array.
if (!is_array($data[array_rand($data)])) {
$data = [$data];
}

// Create the mold for a single row insert.
$insertData = '(';

Expand Down
4 changes: 0 additions & 4 deletions Sources/Db/APIs/PostgreSQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,6 @@ public function insert(string $method, string $table, array $columns, array $dat
// Force method to lower case
$method = strtolower($method);

if (!is_array($data[array_rand($data)])) {
$data = [$data];
}

// Replace the prefix holder with the actual prefix.
$table = str_replace('{db_prefix}', $this->prefix, $table);

Expand Down
2 changes: 1 addition & 1 deletion Sources/Db/DatabaseApiInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function free_result(object $result): bool;
* @param string $method INSERT or REPLACE.
* @param string $table The table (only used for Postgres).
* @param array $columns An array of the columns we're inserting the data into. Should contain 'column' => 'datatype' pairs.
* @param array $data The data to insert.
* @param array[][] $data The data to insert, left rows right columns.
* @param array $keys The keys for the table, needs to be not empty on replace mode.
* @param object $connection = null The connection (if null, $db_connection is used).
* @param int returnmode 0 = nothing(default), 1 = last row id, 2 = all rows id as array.
Expand Down