mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Refactoring the Model::_ _saveMulti() to use one INSERT statement instead of looping over each value and querying INSERT.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5366 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
2c7f16d1f1
commit
2e54eb1706
1 changed files with 7 additions and 1 deletions
|
@ -1134,9 +1134,15 @@ class Model extends Overloadable {
|
|||
|
||||
if (!empty($newValue[$loopAssoc])) {
|
||||
$secondCount = count($newValue[$loopAssoc]);
|
||||
$insertValues = null;
|
||||
|
||||
for ($x = 0; $x < $secondCount; $x++) {
|
||||
$db->query("INSERT INTO {$table} ({$fields[$loopAssoc]}) VALUES {$newValue[$loopAssoc][$x]}");
|
||||
$insertValues .= $newValue[$loopAssoc][$x];
|
||||
if($x < $secondCount - 1) {
|
||||
$insertValues .= ', ';
|
||||
}
|
||||
}
|
||||
$db->query("INSERT INTO {$table} ({$fields[$loopAssoc]}) VALUES {$insertValues};");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue